【发布时间】:2011-11-15 03:40:28
【问题描述】:
我有一个名为“myLocation”的 CLLocation 管理器。
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公里......等等是否应该改变......
-
但如果设备静止,位置更新也会发生。
-
您的意思是即使设备静止,您也可以获取该位置的坐标....?
-
是的。当位置更新发生且设备静止时,当前位置更改的坐标确实会发生变化。这个变化很小(只有小数点后 5 位变化)
-
它多久改变一次?你能显示一些你的代码吗?