2014-09-20 52 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

相關問題