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];
的locationEnabledBool
值始終爲YES
,獨立的位置服務是否被啓用。任何身體可以幫助嗎?檢查locationServicesEnabled總是返回YES,無論手動撥動開關來決定,如果位置服務已啓用
'if([CLLocationManager locationServicesEnabled] == NO && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { //提供錯誤信息 }'在第一個[括號]中有一個小錯字,而& – kalafun