限制UITableView的滚动 [英] Limit the scroll for UITableView
问题描述
我有一个TableViewController:
I have a TableViewController:
如你所见,我在顶部有自己的自定义栏。
UITable View只是一个 static
一个,我在UITableView的顶部添加了一个视图。
As you see I have my own custom bar at the top.
The UITable View is just a static
one, and I add a view at the top of UITableView.
当我将TableView滚动到顶部时,它变得像波纹图像,我不想要它。是否有任何简单的代码可以限制tableView的滚动?
The thing is when I scroll the TableView to top-side it become like bellow image, and I don't want it. is there any easy code that I can limit the scroll for the tableView?
推荐答案
由于UITableView是UIScrollView的子类,因此您可以使用此UIScrollViewDelegate方法禁止在顶部边框上方滚动
since UITableView is a subclass of UIScrollView you can use this UIScrollViewDelegate method to forbid scrolling above the top border
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.tableView) {
if (scrollView.contentOffset.y < 0) {
scrollView.contentOffset = CGPointZero;
}
}
}
这篇关于限制UITableView的滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!