Reputation: 1578
I have UITabBarController which each item has NavigationController and each NavigationController has a TableViewController as root view controller.
The problem is tapping on each tab bar item doesn't make table view to scroll to top.
What could be problem and how can I solve it?
Upvotes: 0
Views: 1124
Reputation: 8516
Check if your tab items is double tapped or not. If yes, then scrollsToTop like below:-
Add below code:-
-(void)viewWillAppear:(BOOL)animated{
[tableView scrollsToTop];
}
Upvotes: -2
Reputation: 1578
Well the answer is this:
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
MasterTableViewController * theViewController;
if (tabBarController.selectedViewController == viewController)
{
if ([viewController isKindOfClass:[UINavigationController class]])
{
UINavigationController * nav = (UINavigationController *)viewController;
theViewController = (MasterTableViewController *)nav.topViewController;
}
else
{
theViewController = self;
}
if ([theViewController respondsToSelector:@selector(navigationBarDoubleTap:)])
{
[theViewController navigationBarDoubleTap:nil];
}
}
return YES;
}
Upvotes: 1