在iOS上检查位置服务权限 [英] Checking location service permission on iOS

查看:208
本文介绍了在iOS上检查位置服务权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I check if location service is enabled for my app?

我有2个情节提要,我想检查位置服务.如果为我的应用程序启用了位置服务,我想启动具有位置的地图故事板.否则,我要启动另一个情节提要.我该如何以编程方式进行操作?

I have 2 storyboards and I want to check location service. If location service enabled for my app, I want to launch map storyboard with location. Otherwise, I want to launch another storyboard. How can I do programmatically?

推荐答案

这是正确的.

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上检查位置服务权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆