-1
-(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?我需要让其中一个按钮转到另一个页面。换句话说,如果我说“是”、“我想继续”并单击“继续”,它将带我进入另一个故事板。

编辑:看看上面写着“我在这里放什么”的部分,那是我想知道要输入什么代码的地方,这样我就可以做我想做的了?

4

1 回答 1

2

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

-(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];
    }
}
于 2013-02-13T04:21:13.770 回答