我想知道如何使2 UIAlertView,3按钮,UIAlertViews(2)需要不同,选项和操作......怎么样?2个带3个按钮的UIAlertView?
0
A
回答
8
试试这个:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Message." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"Button 2", @"Button 3", nil];
alert.tag = 1;
[alert show];
然后再做下一个alertView相同,只是改变标签2
然后只需运行该方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(alert.tag == 1) {
//the alert tag 1 was just closed - do something
}
}
而且 - 确保你包括UIAlertViewDelegate
+1
完美之一... – 2011-03-05 11:37:58
0
只需在alertviews(4)委托方法中检查2,alertviews负责调用方法(1)。
0
UIAlertview代表已在i中弃用os 9.0
此外,当您添加多个然后2个按钮时,它们将由IOS垂直分配。
你可以做简单的UIAlertController
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:[[[NSBundle mainBundle] infoDictionary]
objectForKey:@"CFBundleDisplayName"]
message:@"share via"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* fbButton = [UIAlertAction
actionWithTitle:@"Facebook"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* twitterButton = [UIAlertAction
actionWithTitle:@"Twitter"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* watsappButton = [UIAlertAction
actionWithTitle:@"Whatsapp"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* emailButton = [UIAlertAction
actionWithTitle:@"Email"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* cancelButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Handel no, thanks button
}];
[alert addAction:fbButton];
[alert addAction:twitterButton];
[alert addAction:watsappButton];
[alert addAction:emailButton];
[alert addAction:cancelButton];
[self presentViewController:alert animated:YES completion:nil];
相关问题
- 1. 带19个按钮的UIAlertView
- 2. Android - 带3个按钮的地图
- 3. Angular 2:带多个按钮的NgForm
- 4. 带2个按钮的警报
- 5. iphone sdk-带图像的UIAlertView按钮
- 6. 整理2 UIalertview的按钮点击
- 7. 带2个按钮的单选按钮助手
- 8. ,2个按钮
- 9. UIAlertView按钮到另一个ViewController
- 10. 2 UIAlertView一个接一个
- 11. 如何创建一个带3个选项的切换按钮...?
- 12. 带有2个TextViews和1个按钮的Android ListView
- 13. UIAlertView按钮操作?
- 14. UIAlertView按钮标记
- 15. 多个UIAlertView;每个都有自己的按钮和动作
- 16. 确定在两个UIAlertView中的一个中按下了哪个按钮
- 17. TextField覆盖UIAlertView的按钮
- 18. 按钮被其他2个按钮
- 19. 带两个功能的一个按钮
- 20. 带有2个单选按钮的单按钮,以及alertdialog的视图
- 21. 带有2个按钮的iPhone上的UIAlertView。如何让他们看起来一样?
- 22. 带有2个图像和xamarin格式的文本的按钮
- 23. 如何添加一个buttton2,同时点击另一个按钮1和按钮3,同时点击按钮2
- 24. Bootstrap 3 - 切换 - 2个按钮,2个元素 - 如何显示/隐藏?
- 25. 带有多个(2)网页浏览的后退按钮
- 26. 带有2个均匀间隔按钮的Android布局
- 27. 带有2个按钮的Jquery.post提交表单
- 28. 带有2个按钮的分段控件
- 29. 带2个图像提交按钮的HTML表单
- 30. IE7工具栏按钮,带有2个不同的* .rc文件
你有什么已经尝试过?实现这个问题到底有什么问题? – Vladimir 2011-02-16 21:42:38