代码之家  ›  专栏  ›  技术社区  ›  hg56

UINavigationController到UITabBarController

  •  0
  • hg56  · 技术社区  · 8 年前

    我的应用程序的第一部分是带有内置导航控制器的登录部分。注册部分完成并创建新用户后,我希望进入UITabBarController,并为每个选项卡添加单独的导航控制器。现在,当注册完成并显示我的UITabBarController时,它仍然会显示我应用程序第一部分中的UINavigationController。进入新的UITabBarController后,如何退出UINavigationController?

    enter image description here

    enter image description here

    这是密码

    import UIKit
    
    class SignUpSecondViewController: UIViewController, BEMCheckBoxDelegate {
    
    @IBAction func completeButtonAction(_ sender: Any) {
    
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "NewTabBarViewController") as! UIViewController
        // Alternative way to present the new view controller
        self.navigationController?.show(vc, sender: nil) 
    }
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   Navneet Gill    8 年前

    你应该更好地使用

    self.navigationController?.present(vc, animated: true, completion: nil)
    

    通常,一旦主tabbar控制器启动,就不需要注册。在这种情况下,您可以这样做,这将从内存中删除注册。

    let appDelegate = UIApplication.shared.delegate as! AppDelegate)
    appDelegate.window?.rootViewController = vc