如何让动作表按钮转到另一个页面?

时间:2013-02-13 03:18:47

标签: iphone objective-c storyboard uiactionsheet

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        self.label.text = @"Destructive Button Clicked";
    } else if (buttonIndex == 1) {
        self.label.text = @"Other Button 1 Clicked";
    } else if (buttonIndex == 2) {
        self.label.text = @"Other Button 2 Clicked";
    } else if (buttonIndex == 3) {
        self.label.text = @"Cancel Button Clicked";
    }

    /**
     * OR use the following switch statement
     * Suggested by Colin =)
     */

    /*
    switch (buttonIndex) {
        case 0:
            self.label.text = @"Destructive Button Clicked";
            break;
        case 1:
            self.label.text = @"Other Button 1 Clicked";            
            break;
        case 2:
            //???????????
            self.label.text = @"Other Button 2 Clicked";   <<<<<< WHAT DO I PUT HERE???***
            //???????????
            break;
        case 3:
            self.label.text = @"Cancel Button Clicked";
            break;
     }
     */
}

我在self.label等地方放置了什么?我需要让其中一个按钮转到另一个页面。换句话说,如果我说“是”,“我想继续”,我点击“继续”,它将带我到另一个故事板。

编辑: 看看它说“我要放在这里”的部分,这是我想知道要输入什么代码的地方,以便我可以做我想做的事吗?

1 个答案:

答案 0 :(得分:2)

您只需要实例化viewcontroller并使用导航控制器转到该viewcontroller

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == 0)
    {
        NewViewController *newview =  [self.storyboard instantiateViewControllerWithIdentifier:@"NewView"];
        [self.navigationController pushViewController:newview animated:YES];
    }
    else if(buttonIndex==1)
    {
         NewViewController1 *newview1 =  [self.storyboard instantiateViewControllerWithIdentifier:@"NewView1"];
        [self.navigationController pushViewController:newview1 animated:YES];
    }
}