os8 location authorization 錯誤.

今天在XCode6上打開以前寫的地圖時,給我報這個錯 location authorizationios

去網上查了一番,才知道Xcode6對地圖的設置稍有修改
在stackoverflow上找到了答案 iOS 8 : Location Services not working.net

我權當翻譯一遍,記錄一下.翻譯

解決這個問題通常兩個步驟。code

1 在工程info。plist文件中添加下面值,任意一個

>   <key>NSLocationWhenInUseUsageDescription</key>
    <string>The spirit of stack overflow is coders helping coders</string>

    <key>NSLocationAlwaysUsageDescription</key>
    <string>I have learned more on stack overflow than anything else</string>

value值隨意填,會在請求用戶受權時,顯示給用戶.ip

2 接着就在工程中加入這幾行代碼

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

至於這個就看以前填的是哪一個,永久仍是每次都須要受權
requestWhenInUseAuthorizationget

另,英文還能夠的推薦直接看這篇,講解的很好Core Location Manager Changes in iOS 8string

相關文章
相關標籤/搜索