2
我正在開發一款應用程序,它每隔一分鐘左右檢查一次您的位置,以查看您的位置是否發生了變化。我通過使用xCode中的模擬位置來模擬位置更改。首先我會去倫敦,然後當它更新時,我會把它改成東京這樣的東西,然後當再次檢查位置的時候它不會更新,它仍然認爲它在倫敦。CLLocationManager不能返回正確的位置
-(void)recheckLocation{
locationManager = nil;
[recheckLocation invalidate];
locationManager = [[CLLocationManager alloc]init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
geocoder = [[CLGeocoder alloc] init];
[locationManager stopUpdatingLocation];
// Reverse Geocoding
[geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
if (error == nil && [placemarks count] > 0) {
placemark = [placemarks objectAtIndex:0];
NSString *Location = [NSString stringWithFormat:@"%@, %@",placemark.locality, placemark.administrativeArea];
recheckLocation = [NSTimer scheduledTimerWithTimeInterval:60.0f target:self selector:@selector(recheckLocation) userInfo:nil repeats:YES];
} else {
NSLog(@"%@", error.debugDescription);
}
} ];
}
無論我改變位置多少次,它只是每次給我相同的位置,而不是正確的位置。有人能告訴我我做錯了什麼嗎?