UIAlertView without Cancel Button?

Chris picture Chris · Aug 31, 2011 · Viewed 9.4k times · Source

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];

Answer

Wédney Yuri picture Wédney Yuri · Jul 10, 2015

I did differently, passing cancelButtonTitle argument as nil.

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