【问题标题】:ALAssetsLibraryChangedNotification not being triggered in ios5?ios5 中未触发 ALAssetsLibrary 更改通知?
【发布时间】:2012-03-10 13:08:49
【问题描述】:

我已经在 ios4 中实现了 ALAssetsLibraryChangedNotification 并且它运行良好,但是现在在 ios5 中它似乎被忽略了。我补充:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ALAssetsLibraryChangedNotification) name: ALAssetsLibraryChangedNotification object:self.library]; 

在我的视图控制器初始化器和 dealloc 中我放了:

[[NSNotificationCenter defaultCenter] removeObserver:self name:ALAssetsLibraryChangedNotification object:nil];

那么methdod实现本身就是:

- (void) ALAssetsLibraryChangedNotification
{
//doSomeStuff

}

我需要在初始化程序中添加它并在 dealloc 中删除它,以便如果用户在应用程序外更改库时它会更新。有人知道这个问题的好方法吗?

【问题讨论】:

  • 这是一个iOS5's bug。因此,我们必须采取我写的链接中描述的解决方法。

标签: iphone objective-c ios cocoa-touch ios5


【解决方案1】:

我认为他的意思是:

  1. 调用 [self.assetsLibrary writeImageToSavedPhotosAlbum:nil metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) { }];在创建 ALAssetsLibrary 实例后立即
  2. 观察 ALAssetsLibraryChangedNotification(不是 NSManagedObjectContextObjectsDidChangeNotification)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-28
    • 1970-01-01
    • 2023-03-06
    • 2021-12-06
    • 1970-01-01
    相关资源
    最近更新 更多