2014-10-28 49 views
0

我在ios 8中使用此代碼當前位置,但是這給第三行上的錯誤 錯誤是「沒有已知的選擇器類的方法requestAlwaysAuthorization」。當前位置在ios 8中的錯誤

if ([CLLocationManager respondsToSelector: 
     @selector(requestWhenInUseAuthorization)]) { 
     [CLLocationManager requestWhenInUseAuthorization]; 
    } 
+0

http://matthewfecher.com/app-developement/getting-gps-location-using -core-location-in-ios-8-vs-ios-7/ – WhiteLine 2014-10-28 07:51:00

+0

http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working – WhiteLine 2014-10-28 07:55:37

回答

1

在iOS 8的SDK,requestAlwaysAuthorization(對於背景位置)或requestWhenInUseAuthorization(位置僅當前景)上CLLocationManager調用開始位置更新之前是需要的。

添加兩個鍵中的plist

<key>NSLocationAlwaysUsageDescription</key> 
<string>Your message goes here</string> 
<key>NSLocationWhenInUseUsageDescription</key> 
<string>Your message goes here</string> 

(保留值留空,則使用默認的消息)