У меня есть UIActionSheet, который я могу успешно вызвать из UIBarButtonItem в моем приложении. Однако, когда я нажимаю на кнопку, которая находится на UIActionSheet, метод, который я пытаюсь заставить его вызвать, кажется, не вызывается, и UIActionSheet исчезает. Мой соответствующий код выглядит так:
В моем файле MapViewController.h:
@interface MapViewController : UIViewController<MKMapViewDelegate, UIActionSheetDelegate>{
В моем файле MapViewController.m:
-(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!");
}
Кто-нибудь может увидеть, где я иду не так? Моя личная догадка в том, что это может быть связано с тем, как я реализую интерфейс UIActionSheetDelegate.