本文共 682 字,大约阅读时间需要 2 分钟。
一般APP首次启动,会有登录界面,需要在AppDelegate里设置rootViewController
self.window.rootViewController = loginVC;//登录成功后,切换根视图,上一个根视图自动释放UITabBarController *tabbar = [[UITabBarController alloc] init];[UIApplication sharedApplication].keyWindow.rootViewController = tabbar;
如果,根视图为A,A --> loginVC是经过 present 模态跳转过来的
self.window.rootViewController = A;......//模态跳转[A presentViewController:nav animated:YES completion:nil];//登录成功后,切换根视图,需要dismiss释放上一个根视图[self dismissViewControllerAnimated:NO completion:^{ UITabBarController *tabbar = [[UITabBarController alloc] init]; [UIApplication sharedApplication].keyWindow.rootViewController = tabbar;}];
参考:https://www.jianshu.com/p/89fb4adc81e2
转载地址:http://wiwin.baihongyu.com/