边开发边学习iOS项目实践中的学习

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

2017-01-10  本文已影响756人  CoderMikeHe
一、概述
二、细坑
  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
上一篇 下一篇

猜你喜欢

热点阅读