[英]CLLocationManager authorization message not show in ios iOS 8.0.1
我启动应用程序时未显示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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.