如何卸载故事板?

时间:2012-10-30 09:13:19

标签: iphone ios ios5 storyboard

我需要卸载故事板并用另一个视图控制器替换根视图控制器。当我完成另一个视图控制器时,我需要卸载他并恢复故事板和根视图控制器。当我尝试替换根视图控制器时,故事板仍然可以与其他视图一起使用。

1 个答案:

答案 0 :(得分:1)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

中的

{
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:DesiredViewController];
}

当你想让storyBoard接管到desiredViewController之后......

使用desiredViewController中的代码

AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
 UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //MainStoryBoard is the name of your storyBorad
        UIViewController* myStoryBoardInitialViewController = [storyboard instantiateInitialViewController];

        [appDelegate.window setRootViewController:myStoryBoardInitialViewController ];