2013-02-25 39 views
1

有人给了我这段代码,对吗?如果是这样,我该如何使用它?我是一个noob,所以你可以用简单的术语来解释我吗?谢谢你们:)使工作表按钮打开另一个ViewController?

- (IBAction)OpenActionSheetButton:(id)sender { 


UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:@"There is no going back, 
are you sure???" delegate:self cancelButtonTitle:@"Cancel" 
destructiveButtonTitle:@"Continue" otherButtonTitles:nil, nil]; 
[actionsheet showInView:self.view];} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex: 
(NSInteger)buttonIndex 
{ 
if(buttonIndex == 0) 
{ 
UIViewController *controller = [self.storyboard 
instantiateViewControllerWithIdentifier:@"storyboardViewIdentifier"]; 
    //storyboardViewIdentifier is the ViewController identifier you specify in the 
storyboard 

    //PUSH 
    [self.navigationController pushViewController:controller animated:YES]; 
    //Modal 
    [self presentViewController:controller animated:YES completion:Nil]; 
} 

}

回答

0

我不知道用故事板的情况,但随着厦门国际银行的情况下,我需要设置的UINavigationController对象RootViewController的,这样我可以从一个推视图控制器到另一个,我认为在故事板可能是相同的,如果是这样,请参阅这些答案,firstsecond在故事板环境中将导航控制器设置为rootviewcontroller。

相关问题