有人知道-photoLibraryDidChange 方法何时调用吗?

Posted

技术标签:

【中文标题】有人知道-photoLibraryDidChange 方法何时调用吗?【英文标题】:anyone know when the method -photoLibraryDidChange called? 【发布时间】:2015-08-25 06:40:48 【问题描述】:

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

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

【问题讨论】:

【参考方案1】:

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

通常在以下情况下调用它: - (void)applicationDidEnterBackground:(UIApplication *)application 并且未注册: - (void)applicationDidBecomeActive:(UIApplication *)application

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

【讨论】:

以上是关于有人知道-photoLibraryDidChange 方法何时调用吗?的主要内容,如果未能解决你的问题,请参考以下文章

PHPhotoLibraryChangeObserver photoLibraryDidChange: 何时调用?

PHPhotoLibrary - photoLibraryDidChange 在 Swift 中多次调用

有人知道 iText 的一个分支吗? [关闭]

有人知道这里提到的机器描述是啥吗?

有人知道找出一个数字的逻辑是不是是完美平方吗? [复制]

有人知道有效的 OCR (PHP) 吗? [复制]