Limit the scroll for UITableView

后端 未结 5 842
不知归路
不知归路 2021-01-13 14:27

I have a TableViewController:

\"enter

As you see I have my own custom bar at t

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 14:41

    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;
            }
        }
    }
    

提交回复
热议问题