Is there a way to get notified when the user drags a file into iTunes File Sharing and Sync is complete?
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 a开发者_开发百科t 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?
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
- (void)applicationWillResignActive:(UIApplication *)application
is called when the sync starts and - (void)applicationDidBecomeActive:(UIApplication *)application
after the sync is complete
applicationWillResignActive does not work starting with iOS 5.0.
You can use the DirectoryWatcher class in the DocInteraction sample app.
精彩评论