简体   繁体   English

执行从导航控件到标签栏导航 swift4 的 segue

[英]Perform segue from navigation control to tab bar navigation swift4

i am trying to perform segue from the last screen of navigation control (stack - where you can back) to the first screen of tab bar navigation.我正在尝试从导航控件的最后一个屏幕(堆栈 - 您可以返回的位置)执行 segue 到选项卡栏导航的第一个屏幕。 The only thing i success so far is to open the first screen of the tab bar without the bottom tabs and with back button on the top.到目前为止,我唯一成功的是打开标签栏的第一个屏幕,没有底部标签,顶部有后退按钮。 any idea?任何的想法?

  func userLogin(status: Bool, user: UserModel) {
    DispatchQueue.main.async {
        if status == true{
            self.userModel = user
            self.performSegue(withIdentifier: Constants.gotoOverview, sender: self)
        } else {
            let alert = UIAlertController(title: "Register", message: "some message", preferredStyle: UIAlertController.Style.alert)
            alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
            self.present(alert, animated: true, completion: nil)
        }
    }
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let vc = segue.destination as! OverviewController
    vc.userModel = userModel
}

why you are doing with segue when you can done this work by set root view controller to the first view controller.当您可以通过将根视图控制器设置为第一个视图控制器来完成这项工作时,您为什么要使用 segue。

for ex:- at the end of the navigation screen you want to set first screen as a root view controller.例如:- 在导航屏幕的末尾,您希望将第一个屏幕设置为根视图控制器。

if your tabbar icon not appear then you can also create your tabbar vc identifer and set that controller as your current vc and it will work.如果您的标签栏图标没有出现,那么您还可以创建您的标签栏 vc 标识符并将该控制器设置为您当前的 vc,它会起作用。

when you are on your last vc(View Controller) then use the navigation to push your vc.当您在最后一个 vc(视图控制器)上时,然后使用导航推送您的 vc。

     let storyBoard = UIStoryboard(name: "Main", bundle: nil)
    let vc: UIViewController = 
    storyBoard.instantiateViewController(withIdentifier: TabBarVC)
    self.navigationController?.pushViewController(vc, animated: true)

创建标签栏控制器类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM