ios 11 定位权限没有弹出
-(void)requestWhenInUseAuthorization {if (![self getUserLocationAuth]) {self.locationManagerSystem = [[CLLocationManager alloc]init];if ([self.locationManagerSystem respondsToS...
·
-(void)requestWhenInUseAuthorization {
if (![self getUserLocationAuth]) {
self.locationManagerSystem = [[CLLocationManager alloc]init];
if ([self.locationManagerSystem respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManagerSystem requestWhenInUseAuthorization];
}
}
}
- (BOOL)getUserLocationAuth {
BOOL result = NO;
switch ([CLLocationManager authorizationStatus]) {
case kCLAuthorizationStatusNotDetermined: //用户没有选择是否要使用定位服务(弹框没选择,或者根本没有弹框)
break;
case kCLAuthorizationStatusRestricted: //定位服务授权状态受限制,可能由于活动限制了定位服务,并且用户不能改变当前的权限,这个状态有可能不是用户拒绝的,但是也有可能是用户拒绝的
break;
case kCLAuthorizationStatusDenied: //用户在设置中关闭定位功能,或者用户明确的在弹框之后选择禁止定位
[self openAlertView];
break;
case kCLAuthorizationStatusAuthorizedAlways:
result = YES;
break;
case kCLAuthorizationStatusAuthorizedWhenInUse:
result = YES;
break;
default:
break;
}
return result;
}
更多推荐
已为社区贡献20条内容
所有评论(0)