xcode UIImageWriteToSavedPhotosAlbum 在 iOS 6 iPad 3 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12968486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:52:24  来源:igfitidea点击:

UIImageWriteToSavedPhotosAlbum does not work in iOS 6 iPad 3

xcodeuiimageios6photoipad-3

提问by user1571685

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.

它适用于 iOS 5.1.1 设备和 iPod/iPhone iOS 6.0 设备。

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

但奇怪的是,照片保存在 iOS 6.0 的 iPad 3 上不起作用并返回以下错误:

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

错误域=ALAssetsLibraryErrorDomain 代码=-3310“数据不可用” UserInfo=0x1cd6afc0 {NSLocalizedRecoverySuggestion=启动照片应用程序,NSUnderlyingError=0x1cdaa140“数据不可用”,NSLocalizedDescription=数据不可用}

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

有没有人遇到过这个问题,有什么处理方法?

回答by Loozie

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.

我能够保存到相机胶卷,但是当我升级到 iOS 6 时它停止工作。事实证明,我的应用程序需要(但没有,这是 iOS 6 中的新功能)访问相机胶卷的权限。要获得许可,请转到设置 -> 隐私 -> 照片。我可以再次使用 UIImageWriteToSavedPhotosAlbum() 保存到相机胶卷。

回答by EugeneK

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)

正在将图像写入相机胶卷相册。在没有相机的 iOS 设备上使用时,此方法会将图像添加到“保存的照片”相册而不是“相机胶卷”相册。( UIKit 函数参考)

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.

您的 iPad 上似乎没有“相机胶卷”或“已保存的照片”相册,并且UIImageWriteToSavedPhotosAlbum()找不到匹配的相册来保存照片。

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

启动错误恢复建议中提到的照片应用程序:NSLocalizedRecoverySuggestion=Launch the Photos application
然后尝试通过相机应用程序拍照。