错误:更新时不提示进行位置授权

时间:2015-04-07 10:37:25

标签: ios

2015-04-07 13:26:10.767 harita [1690:821533]尝试启动MapKit位置updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

1 个答案:

答案 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/