Resetting a View With a Tab Item

So I have a TabView in my app and I want to go back to the original view when that tabItem is pressed. For example, when you open the App Store and go to the games tab, click on a game. It takes you to a navigation link to a new view. You can either go back to the first page by pressing the arrow, or by tapping the “games” tabItem again. I want to be able to press my tabItem in a subview of the same tab to go back to the original view that the tab is assigned to.

Any help would be greatly appreciated! Thanks.

Not sure I understand your problem.

Let me check your set up:

  • You have a TabBarController, with several tabs: tab1, tab2, tab3
  • tab2 goes to a navigationController, with FirstView as root
  • tapping tab2 opens FirstView
  • from FirstView you can navigate to a secondView (with a button for instance connected by segue to next VC in the navigation stack), then to a thirdView
  • secondView shows the tabBar items

What you want:

  • when tapping again tab2 in secondView or in thirdView, return to FirstView

Is that correct ?

I tested and it works.

Here is the storyboard setup:

Resetting a View With a Tab Item
 
 
Q