2015-04-07 20 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/