使用 CLLocationManager
显示弹出消息
允许“AppName”访问您的位置,即使您没有使用该应用程序?
有两个选项不允许和允许 点击允许它触发didUpdateLocations
当点击不允许 它调用的委托(delegate)方法是什么?
最佳答案
如果用户拒绝didFailWithError
调用的权限并且错误类型也是
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
// [manager stopUpdatingLocation];
NSLog(@"error%@",error);
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Can't access your current location! Please check your network connection or that you are not in airplane mode!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
case kCLErrorDenied:{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Location Access has been denied for app name!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
// alert.tag=500;
[alert show];
}
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Can't access your current location!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
}
}
关于ios - 哪个委托(delegate)方法在单击时触发 CLLocationManager 不允许,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26561190/