在didSelectViewController函数中,scrollToTop无法点击tabBarItem

时间:2016-02-29 11:53:39

标签: ios objective-c

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {

    tabBarController = self.router.tabController;

    for(UINavigationController* view in tabBarController.viewControllers) {
        UIViewController* topView = view.topViewController;
        if([topView isKindOfClass:[DiscussMainViewController class]]) {
            viewController = (DiscussMainViewController*)view;
            break;
        } else if([topView isKindOfClass:[JobsMainViewController class]]) {
            viewController = (JobsMainViewController*)view;
            break;
        } else if([topView isKindOfClass:[DailyListViewController class]]) {
            viewController = (DailyListViewController*)view;
            break;
        } else if([topView isKindOfClass:[ProfileTableViewController class]]) {
            viewController = (ProfileTableViewController*)view;
            break;
        }

    }

    if([viewController isEqual:tabBarController.selectedViewController]) {
        if([viewController respondsToSelector:@selector(scrollToTop)]) {
            [viewController performSelector:@selector(scrollToTop) withObject:nil];
        }
    }
}

然而,所有视图控制器中的scrollToTop函数都是那样的

- (void)scrollToTop {
    [self.table setContentOffset:CGPointZero animated:YES];
}

0 个答案:

没有答案