Brandon
Brandon

Reputation: 2171

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

Upvotes: 1

Views: 2017

Answers (2)

Midhun MP
Midhun MP

Reputation: 107131

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

Upvotes: 8

user529758
user529758

Reputation:

I get an error: No visible interface for UIActionSheet.

Care to read it further? The message is actually

No visible interface for UIActionSheet declares the selector initWithTitle:delegate:cancelButtonTitle:otherButtonTitles:

Yes, because there's no initializer named that. You can't "remove" arguments like this (since it changes the name of the method, and why would you expect nonexistent methods to exist?)

You can simply pass nil as the destructive button title instead.

Upvotes: 3

Related Questions