2015-04-07 50 views
-3

2015年4月7日13:26:10.767 HARITA [1690:821533]嘗試啓動MapKit位置updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.錯誤:更新,而不提示進行位置信息授權

+0

你需要做的第一件事情就是添加下列鍵的一個或兩個,以你的Info.plist文件:NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription – Sport

+1

http://nshipster.com/core-location -in-ios-8/ – Sport

+0

仍然會給出錯誤 –

回答

0

在iOS8上你寫下面的代碼

self.locationManager = [[CLLocationManager alloc] init]; 
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; 
// Code to check if the app can respond to the new selector found in iOS 8. If so, request it. 
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { 
    [self.locationManager requestAlwaysAuthorization]; 
    // Or [self.locationManager requestWhenInUseAuthorization]; 
} 

[self.locationManager startUpdatingLocation]; 

而且您還必須在您的plist文件中添加NSLocationAlwaysUsageDescription和要顯示的應用程序消息。

檢查本教程http://www.devfright.com/ios-6-core-location-tutorial/