您的位置:首页 > 其它

自定义分区标题不随着table滑动

2015-09-08 19:24 260 查看
再OC中,table分区标题默认是不随着tableview滑动的,当此分区下面的数据全部滑出界面的时候,分区视图才跟着滑动,在QQ等app上也都采用的这种方式

现在问题来了,我要在滑动table的时候,tableHeadView就跟着一起滑动、

实际上 只需要加入一个函数、

//headView跟随tableView一起滑动

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {

if (scrollView == self.tableView)

{

CGFloat sectionHeaderHeight = 22;

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

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: