【问题标题】:iOS CLLocationManager Turn On Location ServicesiOS CLLocationManager 开启定位服务
【发布时间】:2012-08-12 02:16:56
【问题描述】:

在我的应用中,如果位置服务被关闭,它会提示用户:打开位置服务以允许“MyAPP”确定您的位置。

两个选项按钮是设置和取消。

当用户按下取消时,我该如何处理?

是否有任何方法来处理取消按钮按下?

【问题讨论】:

  • 除了显示如下消息外,您无法执行任何操作:“您需要启用定位服务才能使用 blablabla”。

标签: ios cllocationmanager


【解决方案1】:

也许这可能对你想要的有用。

首先,在你的头文件中符合 UIAlertViewDelegate 协议。

然后有一个你可以实现的委托方法。

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   // if the alert view that appeared has titled "Location Denied" and user pressed on cancel button (cancel button is button at index 0)
   if(alertView.title isEqualToString:@"Location Denied"] && buttonIndex == 0)
   {
       // do something
   }
}

【讨论】:

    【解决方案2】:

    //通过UIAlertview中的Button name你可以访问你按下了哪个Button*

    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

    {
    

    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"cancel"])

      {
    
       }
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-20
      • 2012-07-04
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 2011-06-22
      • 1970-01-01
      相关资源
      最近更新 更多