我有通过UIDocumentInteractionController下载图像的任务,但是当我点击“保存图片”按钮时,它显示错误日志如下:
视频 /Users/khanhnd/Library/Developer/CoreSimulator/Devices/13D3E1DA-DB0A-40C2-81EC-9937C7143A2E/data/Containers/Data/Application/83FD51AB-882A-462C-8804-21602AECB030/Documents/storage/IMG_2793.JPG 无法保存到已保存的相册:错误 Domain = AVFoundationErrorDomain Code = -11828
这是我的代码:
if statusCode == 200 {
let viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewFileStorageController") as! ViewFileStorageController
let data = NSData(contentsOfURL: filePath!)
do {
let object = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
if let dictionary = object as? [String: AnyObject] {
print(dictionary["status"])
let status = dictionary["status"] as! Int
let errorMsg = dictionary["description"] as? String
if status == 400 {
let alertController = SLZAlertController(title:errorMsg, message: nil, preferredStyle: .Alert)
alertController.addAction(SLZAlertAction(title: "OK", style: .Default, handler: nil))
alertController.show(inViewController: self, animated: true)
}
}
} catch {
// Handle Error
}
viewController.pathFileUrl = filePath
print("file path is \(filePath)")
viewController.titleNav = self.nameFile!
self.documentController = UIDocumentInteractionController.init(URL: filePath!)
self.documentController!.presentOptionsMenuFromRect(self.cellFrame!, inView: self.view, animated: true)
我认为在这种情况下,ios认为我的图像是一个视频。但仍然坚持它。请任何人都可以帮我解决这个问题。非常感谢你。