ios - 哪个委托(delegate)方法在单击时触发 CLLocationManager 不允许

标签 ios objective-c delegates cllocationmanager

使用 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/

相关文章:

ios - 多次调用委托(delegate)方法,即使在返回 View 后也是如此

c# - 在构造函数中委托(delegate)调用

iphone - 在后台状态下继续操作

ios - 在 UIView 中的 UISegmentedControl 中切换 View

ios - 在WP7中解析iOS .plist文件

objective-c - 不同方向的 UITabbar 应用程序

objective-c - 管理 NSManagedObject

ios - 修复 ARC 中潜在的内存泄漏

objective-c - 如何在没有手势的情况下以编程方式触发翻页转换?

c# - 我应该如何处理停止的、死亡的线程?活着 == 假