年年有"余"

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2572|回复: 0

如何判断当前App是否允许使用系统定位功能

[复制链接]
  • TA的每日心情

    2024-10-15 10:05
  • 签到天数: 372 天

    [LV.9]以坛为家II

    发表于 2015-3-9 11:33:34 | 显示全部楼层 |阅读模式
    如题解答:利用CLLocationManager的一个类方法
    [Objective-C] 纯文本查看 复制代码
    + (CLAuthorizationStatus)authorizationStatus
    // CLAuthorizationStatus是一个枚举值:
    typedef enum {
        kCLAuthorizationStatusNotDetermined = 0, // User has not yet made a choice with regards to this application
        kCLAuthorizationStatusRestricted,        // This application is not authorized to use location services.  Due
                                                 // to active restrictions on location services, the user cannot change
                                                 // this status, and may not have personally denied authorization
        kCLAuthorizationStatusDenied,            // User has explicitly denied authorization for this application, or
                                                 // location services are disabled in Settings
        kCLAuthorizationStatusAuthorized         // User has authorized this application to use location services
    } CLAuthorizationStatus;
    所以,一切变得简单了
    [Objective-C] 纯文本查看 复制代码
        // 判断本地定位服务开启
        if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied){
            // 提示用户开启定位服务,PS:iOS8系统会自动检测额
            [SAAlertView showMessage:@"请在系统设置中打开“定位服务”来允许“XXX”确定您的位置"];
        }

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    手机版|小黑屋|Archiver|iOS开发笔记 ( 湘ICP备14010846号 )

    GMT+8, 2024-12-5 10:29 , Processed in 0.047682 second(s), 22 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表