如何在 iOS 4 中在后台接收 ALAssetsLibraryChangedNotification

发布于 2024-09-28 01:13:33 字数 312 浏览 1 评论 0原文

我想将我的 iOS 4 应用程序注册为 ALAssetsLibraryChangedNotification 的观察者,并在相机胶卷和照片库发生更改时接收通知。最明显的场景是: 1)我的应用程序使用 ALAssetsLibrary 枚举照片内容。 2) 离开我的应用程序(进入后台)并启动相机应用程序。 3)拍照。 4) 离开相机应用程序并返回我的应用程序。

我希望当我的应用程序返回前台时能够传递 ALAssetsLibraryChangedNotification,但情况似乎并非如此。我尝试过 addObserver 的块和选择器形式。当我的应用程序在后台添加或删除照片时,如何接收通知?

I would like to register my iOS 4 app as an observer for ALAssetsLibraryChangedNotification and receive notifications when changes happen to the camera roll and photo library. The most obvious scenario is:
1) My app enumerates photo contents using ALAssetsLibrary.
2) Leave my app (goes into background) and launch the camera app.
3) Take a picture.
4) Leave the camera app and return to my app.

I was hoping the ALAssetsLibraryChangedNotification would be delivered when my app returned to the foreground, but this does not seem to be the case. I've tried both the block and selector form of addObserver. How can I receive notifications when photos are added or removed while my app is in the background?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丑疤怪 2024-10-05 01:13:33

我通过遍历 ALAssetsLibrary 并使用 [[asset defaultRepresentation] url] 存储所有资产 URL 来处理此问题。当我的应用程序激活时,我再次浏览 ALAssetsLibrary,检查我存储的列表。但请注意,URL 格式在 iOS 4.x 和 iOS 5 之间发生变化。

I handle this by walking through the ALAssetsLibrary and storing all the asset URLs using [[asset defaultRepresentation] url]. When my app becomes active I walk through the ALAssetsLibrary again, checking against my stored list. Note however that the URL format changes between iOS 4.x and iOS 5.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文