【发布时间】:2017-02-02 05:48:01
【问题描述】:
当用户点击 tabbar 按钮时,我需要将我的 tableview 滚动到顶部,然后像这样设置。
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
UIViewController *vc = ((UINavigationController *)viewController).viewControllers[0];
static UIViewController *previousController = nil;
if (previousController == vc) {
// the same tab was tapped a second time
SEL selector = NSSelectorFromString(@"scrollToTop");
((void (*)(id, SEL))[vc methodForSelector:selector])(vc, selector);
}
previousController = vc; }
- (void)scrollToTop {
[self.tblListing setContentOffset:CGPointZero animated:NO];
}
问题是滚动停止一半并且它不会滚动到顶部。我需要点击 2-3 次才能滚动到顶部。有什么需要我检查的吗?在我的其他项目中,这没关系。对于这个,我使用自调整大小的单元格。
【问题讨论】:
标签: ios uitableview scroll