iOS UITableView 表头、表尾、段头、段尾 的坑(一)

一、概述
  • 本文主要是针对在iOS开发中,UITableView表头、表尾、段头、段尾的开发过程中的遇到的细坑以及处理方式。
  • 希望能为广大开发提供一点思路,少走一些弯路,填补一些细坑。
二、细坑
  1. 设置UITableViewHeaderUITableViewFooter的高度的坑。

    • 代码
     - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    

{
if (section == 0){
//这里是设置tableView的第一部分的头视图高度为0.01
return 0.01;
}else{
//这里设置其他部分的头视图高度为10
return 10;
}
}
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;//设置尾视图高度为0.01
}

    * 注意 
        - 设置区头区尾的高度,且不能设置为0,那样子没有任何设置效果的 。
        - 如果区尾不需要设置高度,可设置为0.1f。但不能为设置0。
        -  estimatedHeightForFooterInSection 或者 estimatedHeightForHeaderInSection 不要返回 return 0.01。

    * 参考链接:<http://blog.sina.com.cn/s/blog_133384b110102wk8b.html>   

2.  `reason: section footer height must not be negative - provided height for section 49 is -0.001000`。

    * 代码

//- (CGFloat) tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section{
//return 0.001; // 这里不需要返回 否则崩溃
//}

  - (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        return 0.001;

}

   - 参考链接:  <http://blog.csdn.net/arodung/article/details/53375229>

##### 三、期待
1. 文章若对您有点帮助,请给个喜欢❤️,毕竟码字不易;若对您没啥帮助,请给点建议💗,切记学无止境。
2. 针对文章所述内容,阅读期间任何疑问;请在文章底部评论指出,我会火速解决和修正问题。
3. GitHub地址:https://github.com/CoderMikeHe
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容