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:
方法中。
答案 0 :(得分:3)
你正在检查一个常数不是nil,这将永远是真的
您需要检查当前的授权状态:
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)
编辑:RazorSharp提出了一个很好的观点。骆驼套装但以小写字母k开头的东西通常都是常数