I implemented a custom UITabBar solution for a project. In fact, if there are more than 5 elements, I use scrollView, which will allow the user to scroll through additional tabs and suppress more buttons. A similar appearance can be seen in the Weather Channel app.
Each tab bar item corresponds to a UINavigationController, which controls the view stack for each tab. The problem that I encountered is when I have more than 5 tabs, starting from tab 5, it does not correctly support the navigation stack. It seems that moreNavigationController kills the navigation stack every time you return to this tab and you get to the start page again.
I overridden the setSelectedViewController method as follows:
- (void) setSelectedViewController:(UIViewController *)selectedViewController {
[super setSelectedViewController:selectedViewController];
if ([self.moreNavigationController.viewControllers count] > 1) {
self.moreNavigationController.viewControllers = [[NSArray alloc] initWithObjects:self.moreNavigationController.visibleViewController, nil];
}
}
This code will remove the additional functions of the left navigation button, but this will not solve the problem of saving the navigation stack. All other tabs work fine. I can cross several views, and after that I save the stack and return to this tab. I understand that this is a complex problem, so please let me know if there are areas where I can provide clarity. Thank!
Ben m source
share