目标C-CLLocationManager找出何时“允许”执行“确定”。或“不允许”被点击 [英] Objective C - CLLocationManager find out when "Allow" or "Don't allow" is clicked

查看:86
本文介绍了目标C-CLLocationManager找出何时“允许”执行“确定”。或“不允许”被点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行CLLocationManager时,是否存在一个委托方法,当用户单击允许或不允许提示使用位置的请求时会调用该委托方法吗?

When doing CLLocationManager, is there a delegate method that gets called when a user clicked the "Allow" or "Don't allow" prompt that request to use Location?

我尝试了此操作,但是在用户允许或不允许之后却没有得到调用。

I tried this but this doesn't get called after a user "Allow" or "Don't allow".

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;

此外,是否有一个变量可以告诉我用户选择了什么?

Also, is there a variable that will tell me what the user selected?

我尝试了以下操作,但始终返回true。

I tried the below, but that always returns true.

locationManager.locationServicesEnabled

谢谢,

Tee

Thank you,
Tee

推荐答案

为此有一个委托方法

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
    if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) {
        // user allowed
    }

}

这篇关于目标C-CLLocationManager找出何时“允许”执行“确定”。或“不允许”被点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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