Search code examples
iosobjective-cuiactionsheet

Remove Red Destructive Button From ActionSheet


I am trying to have an action sheet that pops up without a destructive button. If I simply try to remove the destructive button from the code below, I get an error: No visible interface for UIActionSheet. Does anyone know why this is happening? How can I remove the red destructive button? Thank you!

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" 
delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive 
Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];

Solution

  • Just pass nil as your destructiveButtonTitle.

    Just try with the below code:

    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];