簡體   English   中英

CLLocationManager授權消息未在iOS iOS 8.0.1中顯示

[英]CLLocationManager authorization message not show in ios iOS 8.0.1

我啟動應用程序時未顯示CLLocationManager授權消息,但已在設備應用程序顯示中簽入了位置服務,但沒有權限。

在xcode 5.1的ios 7中,一切正常,但在ios 8.0的xcode 6.0中,問題

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
    [self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];

謝謝。

在iOS8中,您必須使用requestWhenInUseAuthorizationrequestAlwaysAuthorization請求用戶授權訪問。

並且您已將帶有正確消息的鍵NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription添加到info.plist

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
   [self.locationManager requestWhenInUseAuthorization];
}

暫無
暫無

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

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