简体   繁体   English

CLLocationManager授权消息未在iOS iOS 8.0.1中显示

[英]CLLocationManager authorization message not show in ios iOS 8.0.1

CLLocationManager authorization message not show when i start application i have checked in location service inside device application show but don't have permission. 我启动应用程序时未显示CLLocationManager授权消息,但已在设备应用程序显示中签入了位置服务,但没有权限。

All things are working fine in ios 7 with xcode 5.1 but issue in Xcode 6.0 with ios 8.0 在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];

Thanks. 谢谢。

In iOS8 you have to request the user to authorize the access by using requestWhenInUseAuthorization or requestAlwaysAuthorization . 在iOS8中,您必须使用requestWhenInUseAuthorizationrequestAlwaysAuthorization请求用户授权访问。

And you have add either of the keys NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription with proper messages to the info.plist 并且您已将带有正确消息的键NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription添加到info.plist

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM