一般APP首次啟動(dòng),會(huì)有登錄界面,需要在AppDelegate里設(shè)置rootViewController
self.window.rootViewController = loginVC;
//登錄成功后,切換根視圖,上一個(gè)根視圖自動(dòng)釋放
UITabBarController *tabbar = [[UITabBarController alloc] init];
[UIApplication sharedApplication].keyWindow.rootViewController = tabbar;
如果,根視圖為A,A --> loginVC是經(jīng)過 present 模態(tài)跳轉(zhuǎn)過來的
self.window.rootViewController = A;
......
//模態(tài)跳轉(zhuǎn)
[A presentViewController:nav animated:YES completion:nil];
//登錄成功后,切換根視圖,需要dismiss釋放上一個(gè)根視圖
[self dismissViewControllerAnimated:NO completion:^{
UITabBarController *tabbar = [[UITabBarController alloc] init];
[UIApplication sharedApplication].keyWindow.rootViewController = tabbar;
}];