在ios iOS 8.0.1中不显示CLLocationManager授权消息

时间:2014-09-26 13:21:29

标签: ios ios8

我启动应用程序时未显示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];

感谢。

1 个答案:

答案 0 :(得分:4)

在iOS8中,您必须使用requestWhenInUseAuthorizationrequestAlwaysAuthorization请求用户授权访问权限。

您已将NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription中的任意一项添加到info.plist

的正确消息中
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
   [self.locationManager requestWhenInUseAuthorization];
}