今天在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

相关文章:

  • 2021-09-15
  • 2021-06-07
  • 2022-12-23
  • 2021-07-12
  • 2021-05-16
  • 2021-06-11
  • 2022-01-05
  • 2021-12-06
猜你喜欢
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案