Iphone 当应用程序进入前台时刷新值

Iphone 当应用程序进入前台时刷新值,iphone,ios,alassetslibrary,Iphone,Ios,Alassetslibrary,我的应用程序使用“AlassetGroup”来跟踪用户的相册 我在应用程序中显示这些相册 用户可以单击相册并查看图像 现在,当用户通过safari下载图像或以任何方式更改相册时,问题就出现了 我的应用程序仍然引用旧专辑,而不是新专辑 所以我试着用 - (void)applicationWillEnterForeground:(UIApplication *)application 但这些专辑似乎仍然有着旧的价值, 如果我在应用程序中再次刷新它们,它们将获得正确的值 是否有其他方法可用于解决此问

我的应用程序使用“AlassetGroup”来跟踪用户的相册

我在应用程序中显示这些相册 用户可以单击相册并查看图像

现在,当用户通过safari下载图像或以任何方式更改相册时,问题就出现了

我的应用程序仍然引用旧专辑,而不是新专辑 所以我试着用

- (void)applicationWillEnterForeground:(UIApplication *)application
但这些专辑似乎仍然有着旧的价值, 如果我在应用程序中再次刷新它们,它们将获得正确的值

是否有其他方法可用于解决此问题? 也许是通知

        //This Registers a Notification for any changes
[[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(didChangeLibrary:) 
                                                 name:ALAssetsLibraryChangedNotification 
                                               object:[AGImagePickerController defaultAssetsLibrary]];

- (void)didChangeLibrary:(NSNotification *)notification
{
        //Enter some code here to deal with the album changing
}
编辑:这似乎在iOS5上不起作用(苹果已经打开了一个雷达,因为这是一个bug)

在此期间,可以使用以下变通方法:

召唤

创建库实例后立即观察 AlassetLibraryChangedNotification(非 NSManagedObjectContextObjectsIDChangeNotification)


使用ApplicationDelegate中的
ApplicationIDBecomeActive
方法

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}