从应用程序委托覆盖默认的故事板视图控制器

时间:2012-05-13 04:13:02

标签: ios uiviewcontroller uistoryboard

使用IB故事板时,总会选择默认视图控制器,这是应用程序启动时显示的控制器。

有没有办法在代码中覆盖它?例如,我的app委托逻辑可能需要将用户发送到其他位置。这有可能吗?

1 个答案:

答案 0 :(得分:1)

我将以下所有内容都放在默认控制器上。

- (void)gotoScreen:(NSString *)theScreen
{
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    UIViewController *screen = [self.storyboard instantiateViewControllerWithIdentifier:theScreen];
    [app.window setRootViewController:screen];
}

然后在逻辑发生的地方我会根据需要调用以下内容。

if(myBool == YES) {
    [self gotoScreen:@"theIdentifier"];
}
相关问题