1

有人给了我这个代码,对吗?如果是这样,我该如何使用它?我是菜鸟,所以你能用更简单的术语为我解释一下吗?多谢你们 :)

- (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];
}

}

4

1 回答 1

0

我不确定情节提要的情况,但是对于 XIB 的情况,我需要将 UINavigationController 对象设置为 rootviewcontroller,以便我可以从一个视图控制器推送到另一个,我认为在情节提要中它可能是相同的,如果是这样,请参阅这些答案,第一个第二个将导航控制器设置为故事板环境中的 rootviewcontroller。

于 2013-02-25T06:33:56.870 回答