iPhone 图库在 swift 中选择的图像位置



我需要根据图库中的图像位置(图像拍摄位置纬度和长度(调用 api。任何人都可以帮助我提供正确的指南或示例代码吗

是的,您可以资产 API 并获取图像位置,请查看下面的示例代码

https://gist.github.com/sumitlni/6421aece205ebefa647abe701d2429e0

// this code will be executed with in callback of 
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]).. 
let opts = PHFetchOptions()
opts.fetchLimit = 1
let assets = PHAsset.fetchAssets(withALAssetURLs: [URL], options: opts)
for assetIndex in 0..<assets.count {
let asset = assets[assetIndex]
// print("Location: (asset.location?.description) Taken: (asset.creationDate)")
location = String(describing: asset.location!)
// Here you have the location if it found 
}

最新更新