UIAlertView按钮操作 [英] UIAlertView Button Action
本文介绍了UIAlertView按钮操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用两个动作 UIButton
点击?我有一个UIAlertView显示与两个button.Play再次和退出。我想在点击执行两个方法
How can I use two actions for UIButton
click?I have a UIAlertView showing with two button.Play again and exit.Now i want to execute two method in the click event of these buttons.
推荐答案
UPDATE - 2016年5月
UIAlertView已弃用。您现在可以使用UIAlertController,如此处所述。
-
您可以像这样创建UIAlertView
You can create a UIAlertView like this
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?"
message:@"Do you really want to reset this game?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"reset", nil];
[alert show];
要处理AlertView按钮点击,您必须
符合 UIAlertViewDelegate
协议。
@interface YourViewController:UIViewController<UIAlertViewDelegate>{
.......
.......
}
> UIAlertViewDelegate
协议方法
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == [alertView cancelButtonIndex]){
//cancel clicked ...do your action
}else{
//reset clicked
}
}
这篇关于UIAlertView按钮操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文