我启动应用程序时未显示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];
感谢。
答案 0 :(得分:4)
在iOS8中,您必须使用requestWhenInUseAuthorization
或requestAlwaysAuthorization
请求用户授权访问权限。
您已将NSLocationWhenInUseUsageDescription
或NSLocationAlwaysUsageDescription
中的任意一项添加到info.plist
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}