UIImageWriteToSavedPhotosAlbum does not work in iOS 6 iPad 3

对着背影说爱祢 提交于 2019-12-10 02:04:06

问题


I'm using the next function to save photos in my app:

 UIImageWriteToSavedPhotosAlbum(pngImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);

It works well on iOS 5.1.1 devices, and iPod/iPhone iOS 6.0 devices.

But strangely photo saving doesn't work on iPad 3 with iOS 6.0 and returns the following error:

Error Domain=ALAssetsLibraryErrorDomain Code=-3310 "Data unavailable" UserInfo=0x1cd6afc0 {NSLocalizedRecoverySuggestion=Launch the Photos application, NSUnderlyingError=0x1cdaa140 "Data unavailable", NSLocalizedDescription=Data unavailable}

Did anybody encounter this problem and what are the ways to deal with it?


回答1:


I was able to save to the Camera Roll but when I upgraded to iOS 6 it stops working. It turns out my app needs (but does not have, this is new in iOS 6) permission to access the camera roll. To obtain permission, go to Settings -> Privacy -> Photos. I am able to save to the camera roll with UIImageWriteToSavedPhotosAlbum() again.




回答2:


The image is being written to the Camera Roll album. When used on an iOS device without a camera, this method adds the image to the Saved Photos album rather than to the Camera Roll album. (UIKit Function Reference)

Looks like there are no Camera Roll or Saved Photos albums on your iPad and UIImageWriteToSavedPhotosAlbum() can't find the matching album to save photo.

Launch Photos app as it mentioned in error recovery suggestion: NSLocalizedRecoverySuggestion=Launch the Photos application
and then try to take photo via Camera app.



来源:https://stackoverflow.com/questions/12968486/uiimagewritetosavedphotosalbum-does-not-work-in-ios-6-ipad-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!