我正在尝试跳过登录屏幕,并在用户登录时直接进入MainViewController。但是,问题是我在登录名和主vc之间有一个标签栏控制器和导航控制器。经过广泛的搜索,我写了下面的代码
func showMainViewController() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainViewController: MainViewController = storyboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
let navigationController = UINavigationController(rootViewController: mainViewController)
//It removes all view controllers from the navigation controller then sets the new root view controller and it pops.
window?.rootViewController = navigationController
// //Navigation bar is hidden
// navigationController.isNavigationBarHidden = true
}
尝试一下