gpt4 book ai didi

objective-c - Objective-C - CLLocationManager 找出何时单击 "Allow"或 "Don' t 允许"

转载 作者:太空狗 更新时间:2023-10-30 03:57:56 27 4
gpt4 key购买 nike

在执行 CLLocationManager 时,是否有一个委托(delegate)方法在用户单击“允许”或“不允许”提示请求使用 Location 时调用?

我试过了,但是在用户“允许”或“不允许”后不会调用它。

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

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

我尝试了下面的方法,但总是返回 true。

locationManager.locationServicesEnabled

谢谢你,
三通

最佳答案

有一个委托(delegate)方法

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

}

关于objective-c - Objective-C - CLLocationManager 找出何时单击 "Allow"或 "Don' t 允许",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7579636/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com