当用户将文件拖入 iTunes 文件共享并同步完成时,是否有办法收到通知?

发布于 2024-11-10 01:11:10 字数 168 浏览 0 评论 0原文

当我将 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 技术交流群。

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

发布评论

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

评论(3

晒暮凉 2024-11-17 01:11:10

此外, 框架的 [MPMediaLibary defaultMediaLibrary] 可以发布通知 MPMediaLibraryDidChangeNotification,特别是当您的媒体库被打开时,该通知会被触发。当您的设备与 iTunes 同步时更新。

您可以通过添加以下内容让您的对象观察此通知:

#import <MediaPlayer/MediaPlayer.h>

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(<#selector#>:) name:MPMediaLibraryDidChangeNotification object:[MPMediaLibrary defaultMediaLibrary]];

另外,请确保使用 - (void)beginGenerateLibraryChangeNotifications 激活此通知

Also, <MediaPlayer/MediaPlayer.h> framework's [MPMediaLibary defaultMediaLibrary] can post notification MPMediaLibraryDidChangeNotification, 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:

#import <MediaPlayer/MediaPlayer.h>

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(<#selector#>:) name:MPMediaLibraryDidChangeNotification object:[MPMediaLibrary defaultMediaLibrary]];

Also make sure to activate this notification by using - (void)beginGeneratingLibraryChangeNotifications

谁的新欢旧爱 2024-11-17 01:11:10

- (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 complete

千里故人稀 2024-11-17 01:11:10

applicationWillResignActive 从 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.

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