Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
Created April 1, 2013 07:33
Show Gist options
  • Select an option

  • Save xiangyuan/5283671 to your computer and use it in GitHub Desktop.

Select an option

Save xiangyuan/5283671 to your computer and use it in GitHub Desktop.
tablview single line remove
一.问题
使用UITableViewStylePlain类型的tableView时,如果将separatorStyle设置为UITableViewCellSeparatorStyleSingleLine,就会在每行的下边自动显示一条线,即使是空行也会显示,这样在tableView中无数据时就只会显示一条一条的线,这样可能不是我们想要的效果,如图所示:
空表:
有数据的表:
二.解决方法
有一个简单的方法可以将空行的线去除,即在tableView中添加一个tableFooterView,如果不需要tableFooterView显示什么数据,可以直接添加个空view。
tableView.tableFooterView = [[UIView alloc]init];
三. 结果
修改后的显示效果为:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment