iphone - 如何检测用户是否拒绝使用我的默认位置?

标签 iphone ios objective-c core-location

<分区>

Possible Duplicate:
Determining if user has denied CoreLocation permission

如果用户拒绝在 iOS 应用中“使用我的默认位置”,我将如何检测?

我想根据他们的选择向他们展示不同的 View Controller 。

谢谢

最佳答案

为此,您需要实现以下委托(delegate)方法:

- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
{
    if([error code]== kCLErrorDenied)
        self.locationDenied = YES;

        switch ([error code]) {
        // "Don't Allow" on two successive app launches is the same as saying "never allow". The user
        // can reset this for all apps by going to Settings > General > Reset > Reset Location Warnings.
        case kCLErrorDenied:
            [appDelegate showAllowGPSLocationView];
        default:
            break;
    }

    self.locationDefined = NO;
}

您可以在 AppDelegate 中创建方法“showAllowGPSLocationView”。并向用户显示您需要访问 GPS 位置。

希望它能解决您的问题。

编码愉快!

关于iphone - 如何检测用户是否拒绝使用我的默认位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14580292/

相关文章:

ios - UINavigationBar + largeTitleDisplayMode

ios - 指向同一地址的两个对象不起作用。例如新数组 = 旧数组

ios - CLGeocoder 错误 EXC_BAD_INSTRUCTION

iphone - 检测 UITextField 失去焦点

javascript - 仅通过网页区分 iPhone 型号?

ios - 使用下一个和上一个UIButton切换UITextView/UILabel中的不同文本

ios - 在动画中移动时如何允许触摸 UIButton?

objective-c - 在 DTrace 输出中显示 Objective-C 类

iphone - 自动滚动scrollview

ios - xcode swift UICollectionView 布局 - 单元格大小调整