Abh*_*nav 7 iphone cocoa-touch objective-c cllocationmanager
当我们在应用程序中使用位置服务时,我们会收到iOS警报,说明应用程序正在尝试使用当前位置 - 允许/不允许.
我们是否有代表回拨这些按钮?
我想处理点击"不允许".
Dar*_*ren 16
您无法直接访问该警报.
如果用户按下"不允许",或者如果应用程序没有权限使用位置服务,CLLocationManager则会调用locationManager:didFailWithError:其代理.错误域将是kCLErrorDomain错误代码kCLErrorDenied.
您可以简单地选择如下所示的操作:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) {
[self addRegion];
}
else if (status == kCLAuthorizationStatusDenied) {
NSLog(@"Location access denied");
}
}
Run Code Online (Sandbox Code Playgroud)
确保设置位置管理器的委托.
| 归档时间: |
|
| 查看次数: |
10148 次 |
| 最近记录: |