0

プログラムにこのコードがあります

- (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");
    }
}

コードでわかるように、特定のボタンがクリックされたときにセグエを実行するか、「NSLog」を実行するはずです。

しかし、ボタンをクリックしても、やりたいことが実行されず、代わりにデバッグ領域にこのメッセージが表示されます..

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].

ちなみに、私は のUINavigationController中にある を使っていUITabBarControllerます。これを修正する方法を知っている人はいますか? あなたの助けをいただければ幸いです。ありがとう!

4

1 に答える 1

0

UIActionSheetDelegateデリゲートを .h ファイルに追加し、このように試してみるとうまくいきます。

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];
于 2013-07-03T05:34:57.403 に答える