<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1 我们常用的UITableView 常会用到header ,但这样会带来一个问题 滑动的时候 section 回滑到顶部的时候固定不动 有时我们想要的效果并不是这样 然而解决方案如果用TableView 的group 属性到可以解决 但是会导致在ios6 系统上显示会有问题,那么如何解决该问题呢 下面有两种方案可供参考</span>
一 、嵌入一个UIScrollview 同时设置TableView不可滑动 滑动的时候滑动Scrollview
二、推荐使用,根据scrollView.contentInset
// 解决header 问题
- (void)resetHeader:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 36;
// header的高度
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);
}
}