位置服务警告,即使它们已启用

时间:2013-11-16 17:07:48

标签: ios cocoa-touch

if (kCLAuthorizationStatusDenied) {
    UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@" Please go to settings  and enable them if you want to use all the features of this app  " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [servicesDisabledAlert show];
}

即使启用了位置服务,也会弹出警报。

此代码放在AppDelegate的application didFinishLaunchingWithOptions:方法中。

1 个答案:

答案 0 :(得分:3)

你正在检查一个常数不是nil,这将永远是真的

您需要检查当前的授权状态:

if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)

编辑:RazorSharp提出了一个很好的观点。骆驼套装但以小写字母k开头的东西通常都是常数