i have the following situation:
I got a TabBarController with some tabs(ViewControllers).
When i am in one of these ViewControllers, i tap a button and i want to segue to a NavigationController AND still see the tabbar...
Here is what i did:
- I created a new ViewController(DetailViewController)
- I embedded this new ViewController(DetailViewController) in a NavigationController
- I created a segue(Show) from the "viewcontroller which is embedded in the tabbarcontroller" to the "new navigationcontroller"
I coded:
func buttonTapped { performSegue(withIdentifier: "shownavicontroller", sender: nil } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let destinationNavigationController = segue.destination as! UINavigationController let targetController = destinationNavigationController.topViewController as! DetailViewController }
What goes wrong:
- NavigationController is sliding from bottom to top... it should slide from left to right
- BackButton in NavigationController is missing
- TabBar in NavigationController is missing...
Anybody could help me with this issue?
Thanks and Greetings!!
According to your question i believe this is what you need:
You have done wrong. You should not embed UIViewController directly to tabBarController to get the desired result you want.
From Storybaord,
If you are designing your application from storyboard then you should add a
UIViewController
and embed thisUIViewController
object intoUINavigationController
and then embed thisNavigationController
in aUITabBarController
. So that if a button in aboveUIViewController
is pressed and you need to open an otherUIViewController
not form Bottom to Top but from Left to Right and expecting a Automatic back button at top bar and hide bottom bar. Then you need to create a Push/Show Segue form AboveViewController
(Embed inNavigationController
-> Embed inTabBarController
) to you new UIViewController that will open. And before calling the push/show segue you need to write bellow lines.