这是不允许点击“应用程序想要使用您当前位置”的委托方法?

时间:2013-02-08 06:10:13

标签: iphone ios objective-c geolocation

我想在用户按下弹出窗口时打开弹出窗口“应用程序想要使用您当前的位置”。是否有任何委托方法??

4 个答案:

答案 0 :(得分:5)

Don't you dare reading the documentation...

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
    if (status == kCLAuthorizationStatusDenied) {
        // FA1LZ
    }
}

答案 1 :(得分:0)

检查locationManager:didFailWithError:的{​​{1}}和locationManager:didChangeAuthorizationStatus:

答案 2 :(得分:0)

首先需要获取当前位置。阅读此documentation以获取当前位置。

并使用此方法

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

参数:

1 - 经理
         报告事件的位置管理器对象 2 - 状态
         应用程序的新授权状态。

使用此方法

只要应用程序使用位置服务的能力发生变化,就会调用此方法。由于用户允许或拒绝为您的应用程序或整个系统使用位置服务,因此可能会发生更改。

了解更多信息,请阅读official document

答案 3 :(得分:0)

您可以使用以下委托方法:

- (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;
}

当用户不允许GPS定位时,将调用上面的委托方法。您可以查看“kCLErrorDenied”并处理您想要做的任何事情。

此处,“showAllowGPSLocationView”是在“AppDelegate”中实现的方法,用于通知用户允许GPS定位。

希望,这会对你有所帮助。

快乐编码:)

干杯!

相关问题