iphone - 如何在 UIAlertView (iOS) 中的其他两个按钮(堆叠)之间添加取消按钮

标签 iphone ios customization uialertview cancel-button

我正在尝试创建一个带有三个按钮(将被堆叠)的 UIAlertView。我希望取消按钮位于中间,在其他两个按钮之间。我尝试将 cancelButtonIndex 设置为 1,但如果还有其他两个按钮,它只是将它们放在索引 0 和 1 处。我知道我可以更改按钮的名称,但我想要取消按钮的深蓝色格式.

编辑:** 请注意-我知道如何以正确的顺序获得带有标题的三个按钮,但前提是所有三个按钮基本上看起来都像“其他”按钮;我希望取消按钮具有取消按钮 深蓝色背景,这样它看起来就像一个普通的取消按钮。 **

我试过了

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:button1Title,button2Title,nil] autorelease];
alert.cancelButtonIndex = 1;
[alert show];

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease];
alert.cancelButtonIndex = 1;
[alert addButtonWithTitle:button1Title];
[alert addButtonWithTitle:button2Title];
[alert show];

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:addButtonWithTitle:button1Title,nil] autorelease];
alert.cancelButtonIndex = 1;
[alert addButtonWithTitle:button2Title];
[alert show];

没有用。是否有可能完成我想做的事情?

最佳答案

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self        cancelButtonTitle:nil otherButtonTitles:nil] autorelease];
[alert addButtonWithTitle:button1Title];
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:button2Title];
[alert show];

可能有帮助,

干杯。

关于iphone - 如何在 UIAlertView (iOS) 中的其他两个按钮(堆叠)之间添加取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9996975/

相关文章:

ios - SWRevealViewController 导航栏右键项目

iphone - UIActivityViewController 发送 html 邮件 ios6

android放大/缩小在自定义相机应用程序中不起作用

android - 如何在 Android 中的同一屏幕上运行多个应用程序?

iphone - UIWebView:加载某些 URL 时未调用 webViewDidStartLoad/webViewDidFinishLoad 委托(delegate)方法

iphone - 何时使用 Core Data,何时使用 Sqlite?

iphone - 我想要一个 5 分钟 300kb 的音频文件

ios - AFNetworking 与 put 和 request 主体

iphone - 如何在 objective-c 中声明指针数组

python - Emacs:设置/重置 python 调试断点