TableView viewForHeaderInSection 随滚动条滚动 无遮挡
来源:互联网 发布:淘宝网现状分析 编辑:程序博客网 时间:2024/05/16 14:22
当 TableView 样式属性设置 UITableViewStyleGroup 时,HeaderInSection 会随着滚动,但是每个 Header 会有多余的高度(相比heightForHeaderInSection高度来说)。
当 TableView 样式属性设置 UITableViewStylePlain 时,添加的 HeaderInSection 在滑动时会固定在顶部,与 Cell 重叠
如下图:
解决方案如下:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView == self.tableView) { CGFloat sectionHeaderHeight = 40;//此高度为heightForHeaderInSection高度值 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); } }}
使用如上代码可以解决,HeaderInSection 方法 View 会随着滚动,不会产生遮挡效果
如有导航栏,Table 会被导航栏遮挡,在 ViewDidLoad 中加入如下代码:
self.edgesForExtendedLayout = UIRectEdgeNone;
即可解决导航遮挡 TableView
文章为原创,来自 软曼网:http://www.ruanman.net
0 0
- TableView viewForHeaderInSection 随滚动条滚动 无遮挡
- 左侧滚动无滚动条
- 无滚动条窗口
- 图片随滚动条滚动
- 层随滚动条滚动
- iOS 之tableView 隐藏滚动条
- headerVIew不随tableView 滚动
- 谷歌下解决Pop遮罩层无法遮挡滚动条下问题
- ie浏览器下右侧滚动条会遮挡部分内容
- iOS 11 下 UICollectionView 的HeaderView 遮挡滚动条
- Android实现 ScrollView + ListView无滚动条滚动
- Android实现 ScrollView + ListView无滚动条滚动
- Android实现 ScrollView + ListView无滚动条滚动
- Android实现 ScrollView + ListView无滚动条滚动
- Android实现 ScrollView + ListView无滚动条滚动
- 用绝对定位实现无滚动条的全屏滚动
- Android ScrollView滚动 + ListView无滚动条加载全部内容
- IFrame 无滚动条 载入实际高度
- MFC LNK 2005错误
- Mac下顯示當前文件目錄(配置open cv on ios)
- 金万维怎样用
- STM32使用半主机调试
- IOS6.0自带下拉刷新控件UIRefreshControl
- TableView viewForHeaderInSection 随滚动条滚动 无遮挡
- [Exception Shoot]-NullPointerException when uploading a file(struts文件上传)
- 面试分享(四)-------浙江乾冠信息安全研究院--Android开发
- chrome使用技巧(看了定不让你失望)
- 黑马程序员---初识反射,Class,Constructor,Field
- mac虚拟机突然就不能上网了伤心
- log4cplus 在VS2010安装说明
- OK6410之tftp下载内核,nfs挂载文件系统全过程详解
- 使用代码为 Xcode 工程添加文件