首页 > 其他 > 详细

UITableView 在没有数据时候分割线问题

时间:2016-04-21 18:27:19      阅读:236      评论:0      收藏:0      [点我收藏+]

在iOS4.3中可以直接设置footer为nil,但是在5.0不行,因为UITableView会默认生成一个Footer。

(详见iOS Release Notes中的说明:Returning nil from the tableView:viewForHeaderInSection: method (or its footer equivalent) is no longer sufficient to hide a header. You must override tableView:heightForHeaderInSection: and return 0.0 to hide a header.)

plain类型的tableview当显示的数据很少时,下面的cell即使不显示数据也会有分割线,可以通过下面这个函数去掉多余的分割线。

 

原因:在TableView创建的时候,tableView会默认生成一个Footer。当没有给Footer赋值,或者返回一定的高度的时候,TableView就会存在分割线。

 

解决方法:

1.直接返回一个 趋近0(大于0)的高度,肉眼几乎不可见,则在没有数据时分割线消失。

 

2.设置tableView的TableFooterView = [[UIView alloc] init];

 

3.设置TableView的分割线类型为None;(当数据源为nil时,不为nil时,设置为SingleLine)

 

4.全局设置为None,自定义View给TableView的Cell 加分割线。

UITableView 在没有数据时候分割线问题

原文:http://www.cnblogs.com/MrXHong/p/5417759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!