UIAlertView without Cancel button?

I am trying to create a UIAlertView that has 3 options and does not cancel the button, but when I do this, it always erases the β€œ3” button as the 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]; 
+6
source share
2 answers

This is a message on how to reposition the cancel button. In addition, if you have only 1 button in UIAlertView , then the installation:

 _alertView.cancelButtonIndex = -1; 

A button will appear as a button without canceling. As far as I can tell, if you have more than 1 button, UIAlertView forces the last button to be a cancel button. Looking at the reference may give you an idea of ​​how to set properties to achieve this, but I'm not sure. Hope this helps!

+6
source

I did differently by passing the cancelButtonTitle argument as nil .

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

Source: https://habr.com/ru/post/896257/


All Articles