您的位置:首页 > 产品设计 > UI/UE

tableview 的格式为UITableViewStylePlain,去掉headerview的黏连性

2015-02-09 16:27 363 查看
在viewcontroller中实现如下方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

if (scrollView == _table) {
CGFloat sectionHeaderHeight = 50;
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);
}

}

}
如果是ios7版本以上在viewdidload 实现以下代码,否则会出现滑动后区头被导航条遮住
if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: