Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Controllers with the same root view

So suppose you need some functionality that requires next storyboard. For example you need to upload different content to view depending on what tab is clicked. storyboard

But the problem comes out when you try to use this storyboard. When you switch tabs you getting this behaviour. bad behaviour

But in first tab everything fine. So looks like it doesn't load view second time. Can somebody explain or give a link to the behaviour of navigation controller in this case, because I can't find anything useful in reference. Or how should I correct this behaviour in IB or programatically?
Thanks.

like image 448
htzfun Avatar asked Aug 05 '14 08:08

htzfun


People also ask

How do I get navigation controller root view controller?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller's array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.

How do I navigate a root view controller in Swift?

To go back to root view controller, you can simply call a line of code and your work will be done. And if you have the splash screen and after that the login screen and you want to go to login screen you can simply append presentedviewcontroller in the above code.

What is root view controller in Swift?

The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller's view as the content view of the window.

How do I get the most popular view controller?

In addition, you can check for UINavigationController and ask for its topViewController or even check for UITabBarController and ask for selectedViewController . This will get you the view controller that is currently visible to the user.


1 Answers

a simple work-around is to put a "fake-viewcontroller" as root for the second navigation. On this "fake" controller execute in viewDidLoad a [self performSegueWithIdentifier: @"goToTheControllerHereWeGo" sender: self];

like image 102
Mchurch Avatar answered Oct 13 '22 10:10

Mchurch