Home > DeveloperSection > Forums > Use of destructive button on UIActionSheet in iOS
Karen Green
Karen Green

Total Post:6

Posted on    November-26-2015 1:27 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 913  View(s)
Rate this:

I am creating an application using UIActionSheet. When I implement action sheet I saw an destructive button on the action sheet. My action sheet also contains a 'Cancel' button and when I tap on 'Cancel' button it will dismiss the action sheet,

but I am not understanding what is the role of 'destructive' button here.

Can any one explain me.

Tarun Kumar

Total Post:214

Posted on    November-26-2015 11:32 PM

UIActionSheet's destructive button is added to the action sheet automatically and assigned an appropriate index, which is available from the destructiveButtonIndex property.
destructive button is displayed in red to indicate that it represents a destructive behavior.(if you do not want destructive button then Specify nil in the parameter of action sheet method).
I always use destructive button as a delete button, so that its background color is in red.
Use action sheet's clickedButtonAtIndex: method to set actions on any index button:
Here is the method:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

Modified On Nov-26-2015 11:32:54 PM

Don't want to miss updates? Please click the below button!

Follow MindStick