我已经多次测试该方法,可以肯定的是,当照片库发生变化时,该方法被调用。但在更改之后,该方法将被调用两次(不执行任何操作)。有谁知道为什么
2015-08-25 14:16:04.420 PhotoLibrary[25742:3293667] enter photoLibraryDidChange methods
2015-08-25 14:16:04.445 PhotoLibrary[25742:3283461] something inserted.
2015-08-25 14:16:17.199 PhotoLibrary[25742:3293667] enter photoLibraryDidChange methods
2015-08-25 14:16:17.522 PhotoLibrary[25742:3293668] enter photoLibraryDidChange methods
2015-08-25 14:17:04.762 PhotoLibrary[25742:3295134] enter photoLibraryDidChange methods
2015-08-25 14:17:04.796 PhotoLibrary[25742:3283461] something changed.
2015-08-25 14:17:18.056 PhotoLibrary[25742:3295135] enter photoLibraryDidChange methods
2015-08-25 14:17:18.366 PhotoLibrary[25742:3295137] enter photoLibraryDidChange methods
2015-08-25 14:18:22.915 PhotoLibrary[25742:3297134] enter photoLibraryDidChange methods
2015-08-25 14:18:22.932 PhotoLibrary[25742:3283461] something changed.
2015-08-25 14:18:34.275 PhotoLibrary[25742:3297133] enter photoLibraryDidChange methods
2015-08-25 14:18:34.602 PhotoLibrary[25742:3297130] enter photoLibraryDidChange methods
最佳答案
这是一个委托(delegate)方法,当您的相机胶卷内容发生变化时调用,即如果添加或删除照片。您需要确保您的应用正在监听更改:[[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self];
通常它被调用于:
- (void)applicationDidEnterBackground:(UIApplication *)application
并且未在以下位置注册:
- (void)applicationDidBecomeActive:(UIApplication *)application
您需要导入委托(delegate) <PHPhotoLibraryChangeObserver>
并且您需要确保您的应用具有相机胶卷/照片的权限。
关于ios - 有人知道什么时候调用方法 -photoLibraryDidChange 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32197115/