【发布时间】:2012-10-12 12:06:51
【问题描述】:
我的视图中有 3 个表格视图,我想同时为所有表格启用滚动到顶部功能,即,如果用户点击状态栏,所有三个表格都应该滚动到顶部位置。
我已经尝试使用我所有 tableViews 的 scrollsToTop 属性以及此属性的 YES/No 的各种组合。例如
table1.scrollsToTop = YES;
table2.scrollsToTop = NO;
table3.scrollsToTop = NO;
但无法做到这一点。我们有什么办法可以让点击状态栏的事件,以便我可以尝试将所有表格的内容偏移设置为顶部位置或任何其他解决方法。
任何帮助将不胜感激。
【问题讨论】:
-
通过覆盖下面的 scrollViewShouldScrollToTop 方法解决了这个问题,
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{ [table1 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; [table2 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; [table3 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; return NO; } -
MPG 如果可能,请回答您自己的问题并接受您的回答,以便将此问题标记为“已回答”。谢谢!
-
@Kalle newbie in stackoverflow...这样做
-
我们都是新人。我只是告诉你,因为我在浏览问题时一直在这里结束。 ;)
标签: iphone objective-c uitableview uiscrollview