有没有办法检查用户是否允许我的应用程序使用他/她的位置坐标? 我想在他/她按下按钮提交一些信息之前检查这个,只有在用户允许的情况下我才会激活这个按钮。
我的应用使用 iOS 6。
谢谢
最佳答案
在 CLLocationManager
实例的委托(delegate)中,实现
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
方法。如果调用此方法时将其 error
参数设置为 kCLErrorDenied
,则用户尚未启用位置服务。您还可以实现
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
方法 - 当此回调方法的 status
参数不是 kCLAuthorizationStatusDenied
时,则用户已启用您的应用使用他的位置。
关于ios - 如何检查 userLocation 的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12997270/