我在 viewDidLoad 方法中使用以下代码
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
然后当位置改变时,会连续调用下面的方法。
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
但我只想要一次当前的地理点。有没有什么方法可以直接给你当前的地理点?当我单击某个按钮时,我想计算当前地理点与其他位置之间的距离。如果有人知道请帮助我。
最佳答案
在 中 - (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
你可以调用
[manager stopUpdatingLocation];
关于iphone - 如何在 iPhone 中仅获取一次当前地理点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11209295/