当我设置一个有4行的表格视图时,在填充行的下面仍然有额外的分隔行(或额外的空白单元格)。
如何移除这些单元格?
当我设置一个有4行的表格视图时,在填充行的下面仍然有额外的分隔行(或额外的空白单元格)。
如何移除这些单元格?
当前回答
您可以删除空行分隔符,只需添加脚注的小高度
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
其他回答
迅速:
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView()
}
试试这个。这招对我很管用:
- (void) viewDidLoad
{
[super viewDidLoad];
// Without ARC
//self.tableView.tableFooterView = [[[UIView alloc] init] autorelease];
// With ARC, tried on Xcode 5
self.tableView.tableFooterView = [UIView new];
}
我很幸运地实现了一个被接受的答案(iOS 9+, Swift 2.2)。我尝试着执行:
self.tableView.tableFooterView = UIView(frame: .zero)
然而,对我的tableView没有任何影响-我相信这可能与我使用UITableViewController的事实有关。
相反,我只需要重写viewForFooterInSection方法(我没有在其他地方设置tableFooterView):
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView(frame: .zero)
}
这对于具有单个section的tableView来说效果很好(如果有多个section,则需要指定最后一个)。
Uitableview额外的分隔线隐藏额外的分隔线隐藏在swift 3.0
self.tbltableView.tableFooterView = UIView(frame: .zero)
只需添加一个视图,以所需的分隔符颜色为背景色,宽度为100%,高度为1px,位置为x0 y-1到你的tableViewCell。确保tableViewCell不剪辑子视图,而应该是tableView。
所以你得到了一个绝对简单的和工作的分离只在现有的单元之间没有任何hack每个代码或IB。
注意:在垂直顶部反弹时,第一个分隔符会出现,但这应该不是问题,因为这是iOS的默认行为。