2014-09-26 46 views
0

当我启动应用程序时,CLLocationManager授权消息不显示,我在设备应用程序显示中检查了位置服务,但没有权限。CLLocationManager授权消息不在ios iOS 8.0.1中显示

所有的东西都在IOS 7和Xcode 5.1,但问题在Xcode 6.0与iOS 8.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]; 

由于工作的罚款。

回答

4

在iOS8中,您必须请求用户通过使用requestWhenInUseAuthorizationrequestAlwaysAuthorization来授权访问。

而且你必须添加键NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription适当消息到info.plist

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) 
{ 
    [self.locationManager requestWhenInUseAuthorization]; 
} 
​​是的,我已经检查但这不是工作要么..我想在ipad 2 ..
+1

它应该工作。你可以删除应用程序并重新安装它。重置隐私和位置设置也 – 2014-09-26 13:35:00

+0

我已经检查后删除应用程序和重置设置但stile不工作 self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.distanceFilter = kCLDistanceFilterNone; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; if([self.locationManagerresponseToSelector:@selector(requestWhenInUseAuthorization)]) {[self.locationManager requestWhenInUseAuthorization]; } [self.locationManager startUpdatingLocation]; – 2014-09-26 13:43:47

+0

现在感谢它的工作......我错过了info.plist设置 – 2014-09-29 07:42:23