问题
all.
Recently I am stuck with this error. Here is my codes
if([CLLocationManager locationServicesEnabled]){
NSLog(@"Location Services Enabled");
// Switch through the possible location
// authorization states
switch([CLLocationManager authorizationStatus]){
case kCLAuthorizationStatusAuthorized:
NSLog(@"We have access to location services");
[self loadAnnotations];
MKCoordinateSpan span = MKCoordinateSpanMake(0.04, 0.04);
MKCoordinateRegion region = MKCoordinateRegionMake(locationManager.location.coordinate, span);
[_mapView setRegion:region animated:YES];
break;
case kCLAuthorizationStatusDenied:
NSLog(@"Location services denied by user");
[self loadAnnotations];
[_mapView setRegion:adjustedRegion animated:YES];
break;
case kCLAuthorizationStatusRestricted:
NSLog(@"Parental controls restrict location services");
[self loadAnnotations];
[_mapView setRegion:adjustedRegion animated:YES];
break;
case kCLAuthorizationStatusNotDetermined:
NSLog(@"Unable to determine, possibly not available");
[_mapView setRegion:adjustedRegion animated:YES];
[self repeatCheckLocation];
}
}
else{
// locationServicesEnabled was set to NO
NSLog(@"Location Services Are Disabled");
[self loadAnnotations];
[_mapView setRegion:adjustedRegion animated:YES];
}
This is for a location app that calls some places around the user. It is working on other versions but 6.1. Whenever I run my codes on iOS 6.1 simulator I see it stops at kCLAuthorizationStatusNotDetermined. The weird thing is.. it works while running on my testing device which is iOS 6.1 installed iphone4. I have no idea what when wrong.. Any help would be greatly appreciated
回答1:
It may be an old question, but someone else may find it useful:
There is no way for the Simulator to get the current location as your computer doesn’t have GPS built-in (even you have, Xcode won’t use it). However, the Simulator allows you to fake it.
......
By default, the Simulator doesn’t know its own location. In the menu bar, select “Debug” -> “Location”. The default location is set to “None”. Now change the location setting to “Apple” (or “Apple Stores”).
Check here.
来源:https://stackoverflow.com/questions/15377069/kclauthorizationstatusnotdetermined-occurred-when-tested-with-ios-6-1-simulator