2013-02-25 27 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。

相關問題