6

我正在尝试创建一个具有 3 个选项且没有“取消”按钮的 UIAlertView,但是当我这样做时,它总是将“按钮 3”设置为取消按钮。有没有办法避免这种情况?

UIAlertView *alertView= [[UIAlertView alloc] initWithTitle:@"Select One" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"Button 1",@"Button 2", @"Button3", nil];
4

2 回答 2

8

我做了不同的事情,将cancelButtonTitle参数传递为nil.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
                           message:@"Message here"
                           delegate:self
                           cancelButtonTitle:nil
                           otherButtonTitles:@"OK", nil];
于 2015-07-10T13:33:51.893 回答
6

是一篇关于如何更改取消按钮位置的帖子。此外,如果您在 , 中只有 1 个按钮UIAlertView,则设置:

_alertView.cancelButtonIndex = -1;

将使按钮显示为非取消类型的按钮。据我所知,一旦你有超过 1 个按钮,UIAlertView强制最后一个按钮成为取消按钮。查看参考资料可能会为您提供有关如何设置属性以实现此目的的线索,但我不太确定。希望有帮助!

于 2011-08-30T23:26:00.653 回答