I've been having some trouble with something I thought might be easy. I have a table in my root view controller, when a row is selected I push a new view and from there I go to another tab.
My question is how do I make sure that as soon as the user taps the first tab the navigation controller will pop to root?
Swift 4.2
The solution that works for me is to subclass the UITabBarController and add the two delegate functions as follows:
Make sure you set animated to false otherwise you will get
First, you should create subclass of UITabbarController and add Observer:
When tabbar is selected, We will process in method:
The UTabController suggests a different UX for letting a user "pop to root". When switching back to a tab, it keeps the full UINav stack from before. If they tap the bar item a second time (tapping the selected tab), only then does it pop to root. That's all automatic. Some apps, like instagram, allow a third tap to scroll to top.
I'd suggest sticking with the defaults as that's what users will be expecting.