質問

I have this code on my program

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

as you can see in the code, it supposed to perform a segue or do 'NSLog' when a particular button clicked.

But when I click a button, it does not perform what I want it to do, instead it displays this message in the debug area..

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:].

By the way, I am using a UINavigationController that is inside a UITabBarController. Anyone that has a great idea how to fix this? your help would be much appreciated. Thanks!

役に立ちましたか?

解決

Add UIActionSheetDelegate delegate in .h file and try like this then it'l work.

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];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top