簡體   English   中英

哪個代表方法不允許點擊“應用程序想要使用您的當前位置”?

[英]which is the delegate method for don't allow tap in “App would like to use your current location”?

當用戶在彈出窗口“應用程序要使用您的當前位置”中按下“不允許”時,我想打開一個彈出窗口。 是否有任何委托方法?

您不敢閱讀文檔...

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

檢查CLLocationManagerDelegate locationManager:didFailWithError:locationManager:didChangeAuthorizationStatus: locationManager:didFailWithError:

首先需要獲取當前位置。 閱讀此文檔以獲取當前位置。

並使用此方法

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

參數:

1-經理
報告事件的位置管理器對象。
2-狀態
應用程序的新授權狀態。

使用此方法

只要應用程序使用位置服務的能力發生變化,就會調用此方法。 發生更改的原因是,用戶允許或拒絕為您的應用程序或整個系統使用位置服務。

有關更多信息,請閱讀官方文檔

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

- (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定位。

希望對您有幫助。

快樂編碼:)

干杯!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM