I have a UIActionSheet that I am able to successfully call from a UIBarButtonItem in my app. However, when I click on a button that is on the UIActionSheet, the method that I am trying to get it to call does not appear to be called, and the UIActionSheet goes away. My relevant code looks like this:
In my MapViewController.h file:
@interface MapViewController : UIViewController<MKMapViewDelegate, UIActionSheetDelegate>{
In my MapViewController.m file:
-(IBAction)showActionSheet {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Share your favourite restaurant with your friends" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"EMail",@"Facebook",@"Twitter",nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 0)
NSLog(@"You chose email!");
if(buttonIndex == 1)
NSLog(@"You chose facebook!");
if(buttonIndex == 2)
NSLog(@"You chose twitter!");
}
Can anyone see where I am going wrong? My personal hunch is that it may have something to do with how I am implementing the UIActionSheetDelegate interface.
should be
And also make sure your .h file implements the
UIActionSheetDelegateprotocol