博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 判断定位服务是否开启
阅读量:7001 次
发布时间:2019-06-27

本文共 1068 字,大约阅读时间需要 3 分钟。

-(void)judgeLocationServiceEnabled {

    if ([CLLocationManager locationServicesEnabled] &&

        ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways

         || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse)) {

            //定位功能可用,开始定位

 

//用户从未选择过权限

kCLAuthorizationStatusNotDetermined = 0,

//无法使用定位服务,该状态用户无法改变

kCLAuthorizationStatusRestricted,

//用户拒绝该应用使用定位服务,或者定位服务处于关闭状态

kCLAuthorizationStatusDenied,

//一直开启定位

kCLAuthorizationStatusAuthorizedAlways  

//当使用时开启定位

kCLAuthorizationStatusAuthorizedWhenInUse 

};

        }

    else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied){

        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"定位失败........." preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            

        }];

        [alert addAction:action];

        [self presentViewController:alert animated:YES completion:^{

            

        }];

 

    }

}

转载于:https://www.cnblogs.com/wubao666/p/6003652.html

你可能感兴趣的文章
改善我们的神经网络
查看>>
文件操作的其他模式
查看>>
链表与顺序表的对比
查看>>
windows phone 8 新增功能:从一个应用程序启动另一个程序(file association 和 Protocol association两种方式)...
查看>>
Angularjs总结(七) 路由及请求服务等
查看>>
Bindservice开启服务特点
查看>>
centos session
查看>>
Google Code Jam 2014 资格赛:Problem D. Deceitful War
查看>>
上传文件
查看>>
串口波形分析
查看>>
html5-css列表和表格
查看>>
【Web自动化测试——代码篇十二】自动化测试模型——数据驱动测试和关键字驱动测试...
查看>>
.net判断System.Data.DataRow中是否包含某列
查看>>
Design T-Shirt 排序
查看>>
javaweb项目中关于配置文件web.xml的解析
查看>>
循环语句
查看>>
noip rp++
查看>>
大数加法 (A + B Problem II)
查看>>
Are you sure you want to continue connecting etc ssh ssh_config StrictHostKeyChecking no
查看>>
草稿--cgi
查看>>