ios8在app进行定位的问题上,同ios7 有了一些不同,在ios7当中,只要 对CLLocationManager 类进行实例化,即:
self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager setDelegate:self];
[self.locationManager startUpdatingLocation];
在ios8当中,需要在工程的info.plist文件中添加NSLocationWhenInUseUsageDescription和NSLocationAlwaysUsageDescription两个键值,对应的变量设为YES
同时在实例化时:
self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager setDelegate:self];
[self.locationManager requestAlwaysAuthorization];
[self.locationManager startUpdatingLocation];
添加
[self.locationManager requestAlwaysAuthorization];
这样就可以在ios8当中进行系统定位了
delegate 需要添加的方法还是:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation;
本文介绍了如何在iOS8中正确配置应用的定位服务权限,包括在info.plist中添加必要的键值以及更新CLLocationManager实例化的步骤。
19

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



