您的位置:首页 > 移动开发 > IOS开发

iOS8 - CoreLocation的变化

2015-04-21 14:15 246 查看
并在Info.plist中加入两个缺省没有的字段

NSLocationAlwaysUsageDescription

NSLocationWhenInUseUsageDescription

这两个字段没什么特别的意思,就是自定义提示用户授权使用地理定位功能时的提示语。

CLLocationManager  *locationManager = [[CLLocationManager alloc]init];    locationManager.delegate = self;    [locationManager requestAlwaysAuthorization];    locationManager.desiredAccuracy = kCLLocationAccuracyBest;    locationManager.distanceFilter = kCLDistanceFilterNone;    [locationManager startUpdatingLocation];


这是在调用代理

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {    switch (status) {        case kCLAuthorizationStatusNotDetermined:            if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {                [locationManager requestWhenInUseAuthorization];            }            break;        default:            break;    }}


这样就Ok了,就会弹出原来的提示框

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: