在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 加分割线。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-12-29
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
相关资源
相似解决方案