0
我想使用CLLocationManager獲得上一個按鈕,每個抽頭當前位置,但總是得到相同的座標:(總是得到相同的座標,從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];
}
你通過運行這個模擬器嗎?也許你正在模擬那個位置。檢查調試器上面的Xcode中的小當前位置圖標。 – 2013-02-24 10:16:58