【发布时间】:2012-08-12 02:16:56
【问题描述】:
在我的应用中,如果位置服务被关闭,它会提示用户:打开位置服务以允许“MyAPP”确定您的位置。
两个选项按钮是设置和取消。
当用户按下取消时,我该如何处理?
是否有任何方法来处理取消按钮按下?
【问题讨论】:
-
除了显示如下消息外,您无法执行任何操作:“您需要启用定位服务才能使用 blablabla”。
标签: ios cllocationmanager
在我的应用中,如果位置服务被关闭,它会提示用户:打开位置服务以允许“MyAPP”确定您的位置。
两个选项按钮是设置和取消。
当用户按下取消时,我该如何处理?
是否有任何方法来处理取消按钮按下?
【问题讨论】:
标签: ios cllocationmanager
也许这可能对你想要的有用。
首先,在你的头文件中符合 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
}
}
【讨论】:
//通过UIAlertview中的Button name你可以访问你按下了哪个Button*
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"cancel"])
{
}
}
【讨论】: