【发布时间】:2012-01-11 02:37:24
【问题描述】:
我正在使用模拟器和我的设备来测试它,但无论我做什么,didUpdateToLocation 都不会被调用。我曾尝试更改我在 sim 卡中的位置,关闭然后再次打开我手机上的定位服务,以强制手机搜索新位置……什么都没有。在我的 viewDidLoad() 中,我已经启动了 CLLocationManager:
CLLocationManager *manager = [[CLLocationManager alloc] init];
if (![CLLocationManager locationServicesEnabled])
{
UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[servicesDisabledAlert show];
} else {
manager.desiredAccuracy = kCLLocationAccuracyBest;
manager.delegate = self;
[manager startUpdatingLocation];
}
在更新位置方法中我有这个:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"NEW LOCATION! Accuracy:[%f]",newLocation.horizontalAccuracy);
}
有人知道为什么不调用它吗?
【问题讨论】:
标签: ios xcode mapkit core-location cllocationmanager