我正在尝试从图像中获取位置详细信息,
UIImagePickerControllerReferenceURL
但我发现它PHAsset.fetchAssets(withALAssetURLs: [URL], options: opts)
已被弃用。请帮助我获取位置详细信息。
我们可以用它来做PHAssetCollection
吗?如果是这样,请帮助我
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
{
print(info)
let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
selectedImage.contentMode = .scaleAspectFit
selectedImage.image = chosenImage
dismiss(animated:true, completion: nil)
if let URL = info[UIImagePickerControllerReferenceURL] as? URL {
let opts = PHFetchOptions()
opts.fetchLimit = 1
let assets = PHAsset.fetchAssets(withALAssetURLs: [URL], options: opts)
let asset = assets[0]
print(asset.location)
// The location is "asset.location", as a CLLocation
// ... Other stuff like dismiss omitted
}
}