简体   繁体   English

ALAssetsLibrary ALAssetsLibraryDataUnavailableError

[英]ALAssetsLibrary ALAssetsLibraryDataUnavailableError

I'm trying to make sure to cover all my bases with regard to ALAssetsLibrary failing for whatever reason. 我试图确保涵盖ALAssetsLibrary因任何原因失败的所有基础。 In looking through the possible errors that could occur when calling: 查看调用时可能发生的错误:

- (void)enumerateGroupsWithTypes:usingBlock:failureBlock;

i noticed that ALAssetsLibraryDataUnavailableError, but there isn't much information about what might cause this. 我注意到ALAssetsLibraryDataUnavailableError,但没有太多关于可能导致此问题的信息。 I want to show an error screen accordingly. 我想相应地显示错误屏幕。

Any insight would be appreciated. 任何见解将不胜感激。 Thanks! 谢谢!

I encountered the ALAssetsLibraryDataUnavailableError in 3 cases: 我在3种情况下遇到了ALAssetsLibraryDataUnavailableError:

  1. When using the simulator and switching between iPhone and iPad simulator. 使用模拟器并在iPhone和iPad模拟器之间切换时。
  2. On the device, when the photo library was corrupt or in an inconsistent state. 在设备上,当照片库损坏或处于不一致状态时。
  3. After performing an iOS upgrade without having synced to iTunes. 在没有同步到iTunes的情况下执行iOS升级后。

I would recommend to display a message to the user, you run into this error, recommending: 1. To open the photos app...this usually fixes an inconsistent library. 我建议向用户显示一条消息,您遇到此错误,建议:1。打开照片应用程序...这通常会修复一个不一致的库。 2. If that doesn't help to reboot the Device and sync with iTunes one time. 2.如果这无助于重启设备并与iTunes同步一次。

Cheers, 干杯,

Hendrik 亨德里克

Ok I found out another peculiar circumstance where this error appears: 好的,我发现了出现此错误的另一个特殊情况:

  • Trying to save an UIImage to photo roll/photo album using UIImageWriteToSavedPhotosAlbum. 尝试使用UIImageWriteToSavedPhotosAlbum将UIImage保存到照片卷/相册。
  • iOS asks the user for permission to access the photo library - the user denies(!) iOS要求用户访问照片库的权限 - 用户拒绝(!)

In the completionSelector, the supplied NSError then contains ALAssetsLibrary ALAssetsLibraryDataUnavailableError. 在completionSelector中,提供的NSError随后包含ALAssetsLibrary ALAssetsLibraryDataUnavailableError。

You would think that the error would be something else like ALAssetsLibraryAccessUserDeniedError or ALAssetsLibraryAccessGloballyDeniedError. 你会认为错误是ALAssetsLibraryAccessUserDeniedError或ALAssetsLibraryAccessGloballyDeniedError之类的错误。 But it's not. 但事实并非如此。 It's just ALAssetsLibraryDataUnavailableError. 它只是ALAssetsLibraryDataUnavailableError。

This was tested on iPhone 5, iOS 6.0.1. 这是在iPhone 5,iOS 6.0.1上测试的。 Maybe it's not an error, or it is and they will fix it someday. 也许这不是一个错误,或者它是,他们有一天会修复它。

Anyway, the "fix" is to have the user go into Settings→Privacy→Photos→have your app turned on here. 无论如何,“修复”是让用户进入设置→隐私→照片→打开您的应用程序。 The localized fix suggestion message is WRONG - it suggest to open the Photos app. 本地化修复建议消息错误 - 它建议打开照片应用程序。 No other information about the error given. 没有关于错误的其他信息。 Anyway, the user should probably know that he/she pushed the "Deny" button - still they might have done so by mistake and later they would have no idea what is going on. 无论如何,用户应该知道他/她按下“拒绝”按钮 - 他们可能错误地这样做了,之后他们不知道发生了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM