我正在尝试实现一个共享扩展,将图像从 PhotoLibrary 发布到我的应用程序。但我一直遇到这个错误:
2019-01-13 10:57:14.272148-0800 deegeu-swift-share-extensions-image-share[11664:1341769]
[default] [ERROR] Failed to determine whether URL /var/mobile/Media/PhotoData/OutgoingTemp/F49538B5-7AD5-46EA-BC0E-CEC304DEEB64/IMG_4293.JPG (s)
is managed by a file provider.
这是我正在尝试使用的确切项目源代码:Github Project 这是我密切关注的步骤:Video Tutorial
我的系统信息:iOS 12.1
、iPhone 6s
。
我已在 Xcode 中将应用程序组、开发人员简介等项目信息更新为我自己的。
可能是什么原因?
最佳答案
我认为打印错误来自照片应用程序。对我有用的解决方案是:
itemProvider.loadItem(forTypeIdentifier: kUTTypePNG as String) { [unowned self] (imageData, error) in
if let item = imageData as? NSURL {
let data = NSData(contentsOf : item as URL)
let image = UIImage(data : data! as Data)
print(image)
} else {
if let item = imageData as? UIImage{
print(item)
}
}
}
错误仍然存在,但我创建了我需要的 UIImage 实例。第一个条件是从照片应用程序共享,否则我将获得正确的图像。
关于ios - 共享扩展帖子照片 : Failed to determine whether URL is managed by a file provider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54172225/