I am implementing an alert view after the user clicks on the ‘destructButton’ in an action sheet. Code snippet as below:
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != actionSheet.cancelButtonIndex)
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Something happened!"
message:nil
delegate:nil
cancelButtonTitle:@"Phew!"
otherButtonTitles:nil];
}
[alert show];
[alert release];
}
I have already included the UIActionSheetDelegate protocol in my .h file
@interface Control_FunViewController : UIViewController <UIActionSheetDelegate> {
UITextField *nameField;
UITextField *numberField;
UILabel *sliderLabel;
UISwitch *leftSwitch;
UISwitch *rightSwitch;
UIButton *doSomethingButton;
}
But when I click on the destructButton in the actionsheet, nothing happens. Am I missing something here?
Thanks
Zhen
Your delegate needs to implement
actionSheet:clickedButtonAtIndex:.Action sheet will be dismissed after
actionSheet:clickedButtonAtIndex:and after that the delegate will receiveactionSheet:didDismissWithButtonIndex:.From Apple Action Sheet Delegate Protocol reference
You can have a look at example projects that use UIActionSheet like GenericKeychain :