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:
方法中。
最佳答案
你正在检查一个常量不为 nil,它永远为真
您需要查看当前的授权状态:
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)
编辑:RazorSharp 提出了一个很好的观点。驼峰式但以小写 k 开头的东西通常是常量
关于ios - 位置服务警告,即使它们已启用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20021242/