当用户将文件拖入 iTunes 文件共享并同步完成时,是否有办法收到通知?
当我将 iPhone 插入 iTunes 并将文件拖到应用程序的文件共享部分时,屏幕上的应用程序会消失一会儿然后又回来。看来此时没有任何应用程序委托方法被触发,甚至没有像“转到后台,转到前台”之类的东西。
一旦我的应用程序在用户添加或删除文件的同步后返回,我想更新屏幕。
也许正在发送通知?
When I plug in the iPhone to iTunes and drag a file into the File Sharing section of my app, the app on the screen goes away for a moment and then comes back. It seems that none of the app delegate methods are triggered at this time, not even something like "went to background, went to foreground".
As soon as my app comes back after a sync where the user added or removed files, I want to update the screen.
Maybe there is a notification beeing sent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此外,
框架的[MPMediaLibary defaultMediaLibrary]
可以发布通知MPMediaLibraryDidChangeNotification
,特别是当您的媒体库被打开时,该通知会被触发。当您的设备与 iTunes 同步时更新。您可以通过添加以下内容让您的对象观察此通知:
另外,请确保使用
- (void)beginGenerateLibraryChangeNotifications
激活此通知Also,
<MediaPlayer/MediaPlayer.h>
framework's[MPMediaLibary defaultMediaLibrary]
can post notificationMPMediaLibraryDidChangeNotification
, which is fired especially when your media library is updated while your device is syncing with iTunes.You can let your object to observe this notification by adding:
Also make sure to activate this notification by using
- (void)beginGeneratingLibraryChangeNotifications
- (void)applicationWillResignActive:(UIApplication *)application
在同步开始时调用,- (void)applicationDidBecomeActive:(UIApplication *)application
在同步完成后调用- (void)applicationWillResignActive:(UIApplication *)application
is called when the sync starts and- (void)applicationDidBecomeActive:(UIApplication *)application
after the sync is completeapplicationWillResignActive 从 iOS 5.0 开始不起作用。
您可以在 DocInteraction 示例应用程序中使用 DirectoryWatcher 类。
applicationWillResignActive does not work starting with iOS 5.0.
You can use the DirectoryWatcher class in the DocInteraction sample app.