1.让其Section header footer不动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
UITableView *tableview = (UITableView *)scrollView;
CGFloat sectionHeaderHeight =100;
CGFloat sectionFooterHeight =100;
CGFloat offsetY = tableview.contentOffset.y;
if (offsetY >=0 && offsetY <= sectionHeaderHeight)
{
tableview.contentInset =UIEdgeInsetsMake(-offsetY,0, -sectionFooterHeight, 0);
}elseif (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight)
{
tableview.contentInset =UIEdgeInsetsMake(-sectionHeaderHeight,0, -sectionFooterHeight,0);
}elseif (offsetY >= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height)
{
tableview.contentInset =UIEdgeInsetsMake(-offsetY,0, -(tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight), 0);
}
}
2.- /**
- * 单个cell的刷新
- */
- //1.当前所要刷新的cell,传入要刷新的 行数 和 组数
- NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
- //2.将indexPath添加到数组
- NSArray <NSIndexPath *> *indexPathArray = @[indexPath];
- //3.传入数组,对当前cell进行刷新
- [tableView reloadRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
- /**
- * 单个Section的刷新
- */
- //1.传入要刷新的组数
- NSIndexSet *indexSet=[[NSIndexSet alloc] initWithIndex:0];
- //2.传入NSIndexSet进行刷新
- [tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];