gpt4 book ai didi

ios - 如何使用照片位置数据

转载 作者:行者123 更新时间:2023-11-28 07:01:48 28 4
gpt4 key购买 nike

当我拍照时,我想保存位置(纬度、经度)。我应该在调用 UIImagePickerController, didFinishPickingMediaWithInfo 时使用 locationManager startUpdatingLocation 还是有其他方法从照片中获取位置数据本身

最佳答案

你可以这样做

import CoreLocation

在将 CLLocationManagerDelegate 添加到您的 View Controller 类声明 header 之后

let locationManager = CLLocationManager()
locationManager.delegate = self
if CLLocationManager.authorizationStatus() == .NotDetermined
{


locationManager.requestAlwaysAuthorization()
}


locationManager.startUpdatingLocation()

该代表将要求更改位置

 func locationManager(manager: CLLocationManager!,
didUpdateLocations locations: [AnyObject]!)
{
let location = locations.last as CLLocation
self.locationManager.stopUpdatingLocation()
}

这个委托(delegate)会调用位置管理器有问题

 func locationManager(manager: CLLocationManager!,
didFailWithError error: NSError!)
{

}

希望对您有所帮助。

关于ios - 如何使用照片位置数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31850133/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com