ale*_*ine 7 iphone cllocationmanager
location = [[CLLocationManager alloc] init];
location.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
location.distanceFilter = 10 ;
location.delegate=self;
locationEnabledBool = [CLLocationManager locationServicesEnabled];
if (locationEnabledBool ==NO) {
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];
}
else
[location startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
locationEnabledBool始终是值YES,与是否启用位置服务无关.任何身体都能帮忙吗?
ale*_*ine 11
代替
if (locationEnabledBool == NO) {
//give error message
}
Run Code Online (Sandbox Code Playgroud)
尝试
if ( [CLLocationManager locationServicesEnabled] ==NO || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
//give error message
}
Run Code Online (Sandbox Code Playgroud)
我在链接上找到了这个.
| 归档时间: |
|
| 查看次数: |
3582 次 |
| 最近记录: |