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];
谢谢。
在iOS8中,您必须使用requestWhenInUseAuthorization
或requestAlwaysAuthorization
请求用户授权访问。
您已经将带有正确消息的密钥NSLocationWhenInUseUsageDescription
或NSLocationAlwaysUsageDescription
添加到info.plist
中
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}