1

我已经多次测试该方法,可以肯定的一件事,当照片库发生变化时,该方法被调用。但是在更改之后,该方法将被再次调用两次(不做任何事情)。有谁知道为什么

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
4

1 回答 1

1

它是一个委托方法,当您的相机胶卷内容发生变化时调用,即添加或删除照片。您需要确保您的应用正在监听更改:[[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self];

通常它被调用:
- (void)applicationDidEnterBackground:(UIApplication *)application
并且未注册:
- (void)applicationDidBecomeActive:(UIApplication *)application

您需要导入委托<PHPhotoLibraryChangeObserver>,并且需要确保您的应用具有相机胶卷/照片的权限。

于 2016-01-29T16:12:26.990 回答