今天在XCode6上打开之前写的地图时,给我报这个错 location authorization
去网上查了一番,才知道Xcode6对地图的设置稍有修改
在stackoverflow上找到了答案 iOS 8 : Location Services not working
我权当翻译一遍,记录一下.
解决这个问题一般两个步骤。
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值随意填,会在请求用户授权时,显示给用户.
2 接着就在工程中加入这几行代码
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
至于这个就看之前填的是哪个,永久还是每次都需要授权
requestWhenInUseAuthorization
另,英文还可以的推荐直接看这篇,讲解的很好Core Location Manager Changes in iOS 8