设置tableView 的header和footer失去粘性以及底部出现空白的情况
来源:互联网 发布:网络连接小图标不见了 编辑:程序博客网 时间:2024/05/29 14:32
今天在写代码的时候要求实现header和footer随着视图的滑动而滑动,不需要他们悬浮在tableview头部和尾部的效果
设置header的粘性只需要写出以下方法
-(void)scrollViewDidScroll:(UIScrollView*)scrollView{
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);
}
}
相对于设置header的粘性的方法 设置底部的方法更加简单 只要将tableview的类型设置成group就好了
至于底部留白的情况,我是想利用-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section这个方法设置底部视图却出现了底部留出来大量空白,解决这个问题的方法是舍弃这个方法,直接使用tableview的属性tablefootView就可以了。不同的代码有不同的解决问题,希望能够给大家提供一点帮助吧
- 设置tableView 的header和footer失去粘性以及底部出现空白的情况
- 设置TableView的header和footer
- 自定义tableview Header和Footer的样式
- Plain style tableView禁止header和footer浮动的方法
- iOS7之后的tableView的group布局header以及footer的section
- iOS11 设置tableview的header或者footer高度无效的问题
- android ListView 设置header和footer的问题
- android ListView 设置header和footer的问题
- tableView出现空白的解决方案
- tableView出现空白的解决方案
- jquerymobile header导航和footer底部固定
- ScrollView和WebView 嵌套,底部出现大块空白的问题
- 可以添加Footer和Header的GridView
- RecyclerView添加Header和Footer的基本原理
- RecyclerView添加Header和Footer的方法
- RecyclerView:带header和footer的grid
- RecyclerView优雅的添加Header和Footer
- 自定义UITableView的Header和Footer
- Handler可能引起的内存泄露及解决方案-android
- 17. Letter Combinations of a Phone Number
- [Sencha ExtJS & Touch] 什么是 callParent 和 callSuper ?
- HTML与XHTML的区别?
- ContentProvider组件详解
- 设置tableView 的header和footer失去粘性以及底部出现空白的情况
- leetcode-1 TwoSum
- pod install 与 pod update的区别
- CSS笔试题
- html src文件引入
- MySQL优化
- Android客户端与服务器端数据同步
- neutron的基本原理
- 基于GDI的简单界面框架