ios - 在 iOS 上检查位置服务权限

标签 ios objective-c swift cllocationmanager

如何检查我的应用是否启用了定位服务?

我有 2 个 Storyboard,我想检查定位服务。如果为我的应用启用了位置服务,我想启动带有位置的 map Storyboard。否则,我想启动另一个 Storyboard。如何以编程方式进行?

最佳答案

这是正确的。

if ([CLLocationManager locationServicesEnabled]){

    NSLog(@"Location Services Enabled");

    if ([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){
        alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied"     
                                           message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
                                          delegate:nil 
                                 cancelButtonTitle:@"OK" 
                                 otherButtonTitles:nil];
        [alert show];
    }
}

关于ios - 在 iOS 上检查位置服务权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15153074/

相关文章:

iphone - 检查 iPhone 中的 cookie 是否过期

ios - 查询从 Parse DB 中检索当前登录用户的 BOOL,这将确定要转到的 segue

ios - 尝试重命名 Documents 目录中的文件时出现错误 "file:/..."

swift - 如何仅使用 SwiftUI 从 @main App 访问 NSWindow?

ios - 包装数组索引的最干净方法?

ios - 屏幕分辨率 iOS 设备和图形

ios - 如何处理 UIViewControllerRepresentable 包装器内的 NavigationLink?

ios - 寻找 subviewsDidChange 委托(delegate)方法

ios - 删除所有子项

ios - Alamofire.request 与 manager.request - 经理不工作