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

相关文章
相关标签/搜索