简体   繁体   中英

Segue to a view controller embedded with a tab and navigation controller

The Problem Image

Hello so basically i'm trying to segue from 1 to 2 and show that screen when the button is clicked. What is happening is that the tab controller is not shown but the navigation is when it segued back to view controller 2. I'm not sure if this should be done programmatically or through the storyboard but I tried searching for a solution online and I haven't seen anybody explain this broadly.

You have to change the tabBarController selected item index programmatically like this when the button is tapped,

self.tabBarController?.selectedIndex = 1 // 0 or 1 as you have two tab items

And you have to remove the segue for that ViewController 2 as it is the first ViewController in that tab so once you set the selectedIndex of tabBarController you will get that ViewController

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