ios - 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
}
推荐阅读
- list - 如何检查列表中任何 N 个项目的总和是否等于或大于 Kotlin 中的值
- python - 如何从 __main__.py 访问 __init__.py 中的符号?
- android - 将 Geofirestore 文档结果加载到 RecyclerView
- react-native - ReactNative 中的网络吞吐量
- javascript - js 不执行 'else' 语句
- python - out = [item for t in lt for item in t] 这将如何被执行
- java - 将对象的值与 null 进行比较
- python - 如何修复“ValueError:没有足够的值来解包(预期 2,得到 1)”
- php - 如何在我的网站上弃用对 Internet Explorer 的支持
- c# - context.EnsureCreated() 抛出异常 - 已经是一个名为