ishhhh
ishhhh

Reputation: 647

how to dismiss action sheet with a custom button

I created two buttons and one date picker on the action sheet.On clicking the done button i want to dismiss the action sheet.Can anyone please help with the code for dismissing the action sheet.

i'm using this code for giving action for done button:

[doneButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];

Upvotes: 1

Views: 2893

Answers (4)

Mihai Fratu
Mihai Fratu

Reputation: 7663

You need to keep an instance variable that points to your actionSheet and than in your dismissActionSheet: function just write [actionSheet dismissWithClickedButtonIndex:0 animated:YES];. That should do it.

Upvotes: 1

Sisu
Sisu

Reputation: 716

Implement the delegate <UIActionSheetDelegate>. and paste the following code in button click event.

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];

Upvotes: 3

Maulik
Maulik

Reputation: 19418

in dismissActionSheet method write

[aSheet dismissWithClickedButtonIndex:0 animated:YES];

Upvotes: 1

Praveen S
Praveen S

Reputation: 10393

Implement the UIActionSheetdelegate protocol and you will be good to go. Specifically actionSheet:clickedButtonAtIndex: .

Upvotes: 0

Related Questions