CLLocationManager授权消息未在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中,您必须使用requestWhenInUseAuthorizationrequestAlwaysAuthorization请求用户授权访问。

您已经将带有正确消息的密钥NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription添加到info.plist

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
   [self.locationManager requestWhenInUseAuthorization];
}

最新更新