|
本帖最后由 Ken_DC 于 2014-9-23 15:51 编辑
[_locationManager requestWhenInUseAuthorization];
是_locationManager成员变量。默认是strong的,应该不会被自动释放。
我也实现了代理:
- - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
- switch (status) {
- case kCLAuthorizationStatusDenied :
- {
- // 提示用户出错原因,可按住Option键点击 KCLErrorDenied的查看更多出错信息,可打印error.code值查找原因所在
- UIAlertView *tempA = [[UIAlertView alloc]initWithTitle:@"提醒" message:@"请在设置-隐私-定位服务中开启定位功能!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- [tempA show];
- }
- break;
- case kCLAuthorizationStatusNotDetermined :
- if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
- [_locationManager requestWhenInUseAuthorization];
- }
- break;
- case kCLAuthorizationStatusRestricted:
- {
- // 提示用户出错原因,可按住Option键点击 kCLErrorDenied的查看更多出错信息,可打印error.code值查找原因所在
- UIAlertView *tempA = [[UIAlertView alloc]initWithTitle:@"提醒"
- message:@"定位服务无法使用!"
- delegate:nil
- cancelButtonTitle:@"确定"
- otherButtonTitles:nil, nil];
- [tempA show];
- }
- break;
-
- default:
- break;
- }
- }
复制代码
并且有回调。就是没有alert弹出请求定位服务
进入代理方法:kCLAuthorizationStatusNotDetermined case情况
再次调用[_locationManager requestWhenInUseAuthorization];也没反应
|
|