在Storyboard中以编程方式呈现ViewController

时间:2013-04-24 17:12:22

标签: iphone ios objective-c uiviewcontroller uinavigationcontroller

我正在尝试以编程方式在storyboard中呈现viewcontroller,我正在使用下面提到的代码,但它不起作用,不给我任何回复......

- (void)buttonPressed
{
NSLog(@"called");

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];

UINavigationController *vc = [sb instantiateViewControllerWithIdentifier:@"123"];

vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self.navigationController presentModalViewController:vc animated:YES];
}

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

NSLog(@"called");

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

    UINavigationController *vc = [sb instantiateInitialViewController];

    vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:vc animated:YES completion:nil];