3
Q
带2个按钮的警报
A
回答
6
要把它放到你的头文件:
@interface YourViewController : UIViewController <UIAlertViewDelegate>
把这个入类的提醒:
- (void)alertOKCancelAction {
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Open?" message:@"Open Website?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Open", nil];
alert.tag = 1;
[alert show];
[alert release];
}
添加这个方法:
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
// the user clicked one of the OK/Cancel buttons
if(alert.tag == 1)
{
if(buttonIndex == alert.cancelButtonIndex)
{
NSLog(@"cancel");
}
else
{
NSLog(@"ok");
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.com"]];
}
}
}
+1
我假设你正在制作一个iPhone应用程序...根据你以前的发布历史记录。当你发布你的问题时,你应该指定这个 – Dima 2010-11-22 21:25:28
相关问题
- 1. 带TextInput的Flex警报以及按钮
- 2. 按钮和警报?
- 3. 按钮警报中的多个参数?
- 4. 警报视图按钮
- 5. 警报消息按钮
- 6. 哪个按钮,在警报视图
- 7. 甜警报2和javascript:如何使一个甜蜜的警报按钮,当按下
- 8. 2个带3个按钮的UIAlertView?
- 9. 带有一个,两个和三个按钮的Android警报对话框
- 10. 带有单选按钮的javascript警报框
- 11. 带警报的删除按钮在php中不起作用
- 12. Angular 2:带多个按钮的NgForm
- 13. 如何设置Ionic 2中单选按钮警报的值
- 14. jQuery的节目警报提交按钮
- 15. 警报按钮的内部内容
- 16. JavaScript的按钮返回错误警报
- 17. 带2个按钮的单选按钮助手
- 18. 按顺序显示两个相同的警报视图。如何区分警报1和警报2的文本?
- 19. 警报对话框文本follwed有一个复选框和2个按钮
- 20. 带jQuery的几个选项的警报
- 21. Android:警报对话框,取消按钮
- 22. 关闭按钮不显示Bootstrap警报
- 23. 禁用警报查看按钮
- 24. JQuery按钮不显示警报
- 25. 科尔多瓦警报按钮
- 26. 在警报中禁用确定按钮
- 27. 警报箱,CountDownTimer,后退按钮崩溃
- 28. 单击按钮时运行警报JS
- 29. vue组件和警报点击按钮
- 30. 单击按钮后显示警报
像lolcat下面说,请指定您正在使用的平台。特别是考虑到下面有两个完全不同但正确的答案。 – 2010-11-22 21:33:31