2014-09-20 67 views
1

这里是我的代码:cllocationmanager不要求用户权限iOS8上

if (!_locationManager) 
    { 
     _locationManager = [[CLLocationManager alloc] init]; 
     [_locationManager setDelegate:self]; 
    } 
    [_locationManager startUpdatingLocation]; 

如果有人知道请帮助..谢谢

+1

通过这个去... http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working – 2014-10-13 12:32:11

回答

1

当您使用位置服务iOS-8.0及以上时,您需要添加一个致电requestWhenInUseAuthorization。找到下面的示例代码。

locationManager = [[CLLocationManager alloc]init]; 
locationManager.delegate = self; 

// this check is required for iOS 8+ 
// selector 'requestWhenInUseAuthorization' is first introduced in iOS 8 
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { 
    [locationManager requestWhenInUseAuthorization]; 
} 

[locationManager startUpdatingLocation]; 

欲了解更多信息,请参阅blog

希望这会有所帮助。

2

添加[locationManager requestAlwaysAuthorization];到您的代码,并添加条目NSLocationAlwaysUsageDescription与您的.plist价值是某种你想要求用户许可的消息。

+0

我缺少的.plist进入:) – 2015-10-19 15:40:46

相关问题