UIImagePickerController从用户的照片库
中选择一张图片我想在Swift中获取所选照片的位置坐标...
我尝试过尝试获取照片的网址....
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
let imageURL = editingInfo![UIImagePickerControllerReferenceURL] as! NSURL
self.imageFromAsset(imageURL)
}
并将其传递给......
func imageFromAsset(nsurl: NSURL) {
let asset = PHAsset.fetchAssetsWithALAssetURLs([nsurl], options: nil).firstObject as! PHAsset
var location = asset.location //then do something with this data
}
但是开始使用图片网址会产生致命错误。
希望有人可以提供帮助,谢谢。
错误讯息:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
此行似乎出现此错误:
let imageURL = editingInfo![UIImagePickerControllerReferenceURL] as! NSURL
答案 0 :(得分:0)
使用:
a
而不是:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
因为它在iOS 3.0中已弃用