What slides along with the table is the sectionView of the tableview. You can use table.tableFooterView = [[UIView alloc] init...]; so that it will not move as the table moves down.
Then don’t implement headerView as tableView.
Take headerView as an example, add a section at the front, and then use this headerView as the header of the section. The number of rows in this section is 1 (I heard that there are occasional bugs when it is 0), and the row height is 0, inside cellForRow Just return a cell with the default style.
update: After thinking about it carefully, this can only ensure that this section will not scroll when it is at the top, otherwise it will still scroll out.
The real solution is: instead of placing headerView and footerView in tableView, shorten the height of tableView, place headerView above tableView, and place footerView below tableView.
In fact, if you just want to make a view that does not slide with the tableview, there are two methods 1. Add the view to the NavigationController, so that the view will not slide with the tableview 2. Add the view to the tableview, but Dynamically adjust the coordinates of this view so that its coordinates are always 0. (Involving a small algorithm)
What slides along with the table is the sectionView of the tableview. You can use table.tableFooterView = [[UIView alloc] init...]; so that it will not move as the table moves down.
Then don’t implement headerView as tableView.
Take headerView as an example, add a section at the front, and then use this headerView as the header of the section. The number of rows in this section is 1 (I heard that there are occasional bugs when it is 0), and the row height is 0, inside
cellForRow
Just return a cell with the default style.update: After thinking about it carefully, this can only ensure that this section will not scroll when it is at the top, otherwise it will still scroll out.
The real solution is: instead of placing headerView and footerView in tableView, shorten the height of tableView, place headerView above tableView, and place footerView below tableView.
Just put it on the view.
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
}
In fact, if you just want to make a view that does not slide with the tableview, there are two methods
1. Add the view to the NavigationController, so that the view will not slide with the tableview
2. Add the view to the tableview, but Dynamically adjust the coordinates of this view so that its coordinates are always 0. (Involving a small algorithm)