Ios 从应用程序委托重写默认情节提要视图控制器

Ios 从应用程序委托重写默认情节提要视图控制器,ios,uiviewcontroller,uistoryboard,Ios,Uiviewcontroller,Uistoryboard,对于IB故事板,始终会选择一个默认的视图控制器,该控制器将在应用程序启动时显示 有没有办法在代码中重写这个?例如,我的应用程序委托逻辑可能需要将用户发送到其他位置。这是可能的吗?我将以下所有内容都放在默认控制器上 - (void)gotoScreen:(NSString *)theScreen { AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; UIViewContr

对于IB故事板,始终会选择一个默认的视图控制器,该控制器将在应用程序启动时显示


有没有办法在代码中重写这个?例如,我的应用程序委托逻辑可能需要将用户发送到其他位置。这是可能的吗?

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

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