我想使用 CLLocationManager 在每次点击按钮时获取当前位置,但始终获得相同的坐标:(
- (void)GetCoord
{
self.currentLocation = nil;
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
self.currentLocation = newLocation;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Megerősítés"
message:[NSString stringWithFormat:@"%f ::: %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude]
delegate:self
cancelButtonTitle:@"Nem"
otherButtonTitles:nil
];
[alert show];
[self.locationManager stopUpdatingLocation];
}