iOS8 中使用地图是出现以下错误:
[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthoriz
解决方式:
1:在 info.plist文件中添加
(1)NSLocationAlwaysUsageDescription
(2)NSLocationWhenInUseUsageDescription
这两个键的值就是授权alert的描述,也可以不填,
2:在.m文件内加上如下代码申请授权
if ([CLLocationManager locationServicesEnabled]) {
self.locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest; //控制定位精度,越高耗电量越大。
_locationManager.distanceFilter = 100; //控制定位服务更新频率。单位是“米”
[_locationManager startUpdatingLocation];
//在ios 8.0下要授权
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
[_locattionManager requestAlwaysAuthorization];
[_locationManager requestWhenInUseAuthorization]; //调用了这两句,就会弹出允许框了.
}
本文详细介绍了在iOS8中使用地图时遇到的授权错误问题,并提供了完整的解决方案,包括在Info.plist文件中添加必要的键值对,以及在.m文件内实现授权申请的代码。
382

被折叠的 条评论
为什么被折叠?



