Objective c 使用showInView时,操作表按钮不响应

Objective c 使用showInView时,操作表按钮不响应,objective-c,xcode4.5,uiactionsheet,ios6.1,Objective C,Xcode4.5,Uiactionsheet,Ios6.1,我的程序里有这个代码 - (void)viewDidLoad { [super viewDidLoad]; UIButton *saveMessageBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [saveMessageBtn setImage:[UIImage imageNamed:@"btn_done.png"] forState:UIControlStateNormal]; [saveMessageBtn addTarget:s

我的程序里有这个代码

- (void)viewDidLoad
{
[super viewDidLoad];

UIButton *saveMessageBtn =  [UIButton buttonWithType:UIButtonTypeCustom];
[saveMessageBtn setImage:[UIImage imageNamed:@"btn_done.png"] forState:UIControlStateNormal];
[saveMessageBtn addTarget:self action:@selector(saveMessage) forControlEvents:UIControlEventTouchUpInside];
[saveMessageBtn setFrame:CGRectMake(0, 0, 49, 30)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:saveMessageBtn];
}

-(IBAction)saveMessage:(id)sender{


UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Send Now",@"Non Recurring",@"Recurring", nil];
[actionSheet showInView:self.view];
}

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

if (buttonIndex == 0){
    NSLog(@"Send Now");
}
else if (buttonIndex == 1){
    [self performSegueWithIdentifier:@"modalNonRecurring" sender:self];
}
else if (buttonIndex == 2){
    [self performSegueWithIdentifier:@"modalRecurring" sender:self];
}
else{
NSLog(@"Cancel Clicked");
    }
}
正如您在代码中看到的,当单击特定按钮时,它应该执行segue或do“NSLog”

但是,当我单击按钮时,它不会执行我希望它执行的操作,而是在调试区域显示此消息

显示由superview剪裁的操作表。某些控件可能对触摸不响应。在iPhone上尝试-[UIActionSheet showFromTabBar:]或-[UIActionSheet showFromToolbar:]而不是-[UIActionSheet showInView:]。

顺便说一下,我正在使用
uitabarcontroller
中的
UINavigationController

有谁知道如何解决这个问题吗?非常感谢你的帮助。谢谢

在.h文件中添加
UIActionSheetDelegate
delegate,然后像这样尝试,它就会工作

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Send Now",@"Non Recurring",@"Recurring", nil];
    actionSheet.delegate = self;
    [actionSheet showInView:self.view];

是的,它起作用了!谢谢。每个人都必须给你一个加分,我很抱歉我没有足够的声誉给你一个@SunnyI刚刚做的。再次感谢。:)