我有一個稱爲「myLocation」的CLLocation管理器。位置管理器更新頻率,iphone
myLocation = [[CLLocationManager alloc] init];
myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
myLocation.distanceFilter = 10 ;
myLocation.delegate=self;
locationEnabledBool = [CLLocationManager locationServicesEnabled];
if (locationEnabledBool ==NO || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)) {
// LocationText.text = @"Location Service Disabled ";
UIAlertView *locationAlert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
}
[myLocation startUpdatingLocation];
和位置更新功能是
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"old location is %f, %f ", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@"new location is %f,%f",newLocation.coordinate.latitude, newLocation.coordinate.longitude);
}
有沒有辦法找到位置管理器更新的頻率,如果可以增加或減少?
位置管理器中沒有這樣的選項....只要檢測到位置更改,就會調用委託。但是你可以改變精確度......也就是說,它應該在每十米變化還是100米或1公里變化......等等。 – booleanBoy
但是如果設備靜止,位置更新也會發生。 – alekhine
你的意思是即使設備靜止,你也可以獲得位置的座標....? – booleanBoy