4
votes

In my iPhone app, I have an actionsheet which has 4 buttons.

Now to perform actions on click of these buttons, I have implemented ActionSheet Delegate.

The action sheet delegate method does not get called on click of the buttons. The same code works when integrated to another project.

I have declared all the method names properly.

Below is the screenshot which shows the delegate method

alt text

What could be wrong?

2
Post your code directly rather than showing its imageAditya
Did you set [actionSheet setDelegate:self] or You didn't forget to set delegate to self when you create the actionSheet?EmptyStack
The issue will be in how you create and/or display the action sheet, not in the delegate method.pwc
Simon: I have marked my answer. Please Checkout CMLlyod's Answer.Parth Bhatt
You probably don't want to post your appid on a public forum...memmons

2 Answers

7
votes

Make sure you have set your UIActionSheet delegate to self:

actionSheet.delegate = self;

and also make sure you're implementing <UIActionSheetDelegate> in the header file.

4
votes

If you use the code to call the action sheet like below

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"YOUR TITLE" delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"YOUR MESSAGE" otherButtonTitles:@"Cancel", nil];
[actionSheet showInView:self.view];
[actionSheet release];

Then there won't be an issue calling the delegate method,

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

Cheers