[英]iOS: location services authorization alert view is not displayed when app is started
我幾天前問了這個問題,關於我的應用在重新安裝后沒有顯示在“設置”>“位置服務”下。 我發現,重新安裝后,我必須運行該應用程序並等待顯示“使用當前位置”授權警報視圖,以使該應用程序顯示在“位置服務”列表下。 反過來,我發現我的應用在啟動時不會立即顯示此警報視圖。
這是可能是問題的一些代碼:
-(void)restartGps: (UIWebvView *)curWebView {
[locationManager startMonitoringSignificantLocationChanges];
[self performSelector:@selector(noGpsLock:) withObject:curWebView afterDelay:GPS_TIMEOUT];
}
-(void)noGpsLock: (UIWebView *)curWebView {
if (!hasLocationFix) {
[locationManager stopMonitoringSignificantLocationChanges];
[self performSelector:@selector(restartGps:) withObject:curWebView afterDelay:GPS_TIMEOUT];
}
}
當-locationManager:didUpdateToLocation:fromLocation:
時, -locationManager:didUpdateToLocation:fromLocation:
設置為TRUE。
我最初在viewDidLoad
調用restartGps:
然后讓這兩個方法相互調用。 我發現第一次(從viewDidLoad
)調用restartGps:
,沒有出現警報,因此應用程序無法獲得任何位置。 經過noGpsLock:
和restartGps
調用后,警報最終出現,並且該應用程序能夠獲取位置。
為什么在首次啟動restartGps:
時未顯示警報?
也許此鏈接可以幫助您
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.