iphone - locationServicesEnabled test passes when they are disabled in viewDidLoad -


I have location services disabled for my application in the Settings panel. I run a test in viewDidLoad in my Visual Controller To see if they are enabled:

  if ([CLLocationManager Location Services enabled]) {// do something now}  

This test is always For any reason, if I try and access the location services, then I'll go to the location manager. To get a Kesielarardiandid error. what gives?

Am I using the wrong test?

location services enabled class method tests global settings for location services only Does AFAIK, there is no way to test whether your app has been explicitly rejected or not. You need to wait for the location request to wait and use the CLLocationManagerDelegate method for locationManager: didFailWithError: , whatever you need eg:

  - (Zero) Position Manager: (CLLocationManager *) Manager has a FileWire Error: (NSError *) Error {NSString * errorString; [Manager stopupdating location]; NSLog (@ "Error:% @", [Error localization]]; Switch ([error code]) {user: user errorString = @ "Access denied services denied by user" by kCLErrorDenied: // login error; // do something ... break; Case kCLErrorLocationUnknown: // Perhaps temporary ... errorString = @ "location data unavailable"; // Do something else ... break; Default: errorString = @ "An unknown error has occurred"; break; }} UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "Error" Message: ErrorString Representative: Cancel AutoTitTitle: @ "OK" Other Button Button: Zero, Zero]; [Alerts show]; [Warning issued]; }  

See the documentation on the CLError constant for more options.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -