UIAlertView without Cancel Button?

一个人想着一个人 提交于 2019-12-14 03:45:20

问题


I am trying to create a UIAlertView that has 3 options and no "cancel" button, but when I do this, it always styles "Button 3" as a cancel button. Is there any way to avoid this?

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

回答1:


This is a post about how to change the position of the cancel button. Also, if you have only 1 button in the UIAlertView, then setting:

_alertView.cancelButtonIndex = -1;

Will make the button appear as a non-cancel type button. As far as I can tell though, once you have more than 1 button, the UIAlertView forces the last button to be the cancel button. Looking through the reference may give you a clue about how to set the properties up to achieve this, but I'm not too sure. Hope that Helps!




回答2:


I did differently, passing cancelButtonTitle argument as nil.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
                           message:@"Message here"
                           delegate:self
                           cancelButtonTitle:nil
                           otherButtonTitles:@"OK", nil];


来源:https://stackoverflow.com/questions/7250360/uialertview-without-cancel-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!