简体   繁体   中英

how to hide tab bar in the view controller that embedded in the navigation stack in swift?

在此处输入图片说明

I have an InvoiceVC in the second tab bar ( tab Bar index : 1 ) like the picture above. if the table view cell is tapped, I need to segue to the InvoiceDetailVC like the picture below

在此处输入图片说明

as you can see in the InvoiceDetailVC, there is no tab bar in the bottom of the InvoiceDetailVC, I mean that tab that has red badge in the bottom. I need remove that tab bar.

I have tried to use present modally instead of push show segue. But the problem is, there is no back button to back to InvoiceVC

so what should I do ?

在此处输入图片说明

Use in prepareforsegue while pushing and set hidesBottomBarWhenPushed to true to hide the tabbar on destination view controller.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "InvoiceVC") {
        let indexPath: IndexPath? = tableView.indexPathForSelectedRow
        let destViewController = segue.destination as? InvoiceVC
        destViewController?.recipeName = recipes[indexPath?.row ?? 0]
        destViewController?.hidesBottomBarWhenPushed = true
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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