UINavigationController到UITabBarController

问题描述 投票:0回答:1

我的应用程序的第一部分是一个内置导航控制器的登录部分。当注册部分完成并创建一个新用户时,我想进入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) 
}
swift uinavigationcontroller uitabbarcontroller
1个回答
1
投票

你应该更好地使用

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

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

let appDelegate = UIApplication.shared.delegate as! AppDelegate)
appDelegate.window?.rootViewController = vc
© www.soinside.com 2019 - 2024. All rights reserved.