当我设置一个有4行的表格视图时,在填充行的下面仍然有额外的分隔行(或额外的空白单元格)。

如何移除这些单元格?


当前回答

Swift 3 /Swift 4 /Swift 5 +,非常简单

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
      //MARK:- For Hiding the extra lines in table view.
    tableView?.tableFooterView = UIView()
}

OR

override func viewDidLoad(_ animated: Bool) {
    super.viewDidLoad(animated)
      //MARK:- For Hiding the extra lines in table view.
    tableView?.tableFooterView = UIView()
}

其他回答

我想扩展一下我的回答:

简单地添加高度为0的页脚就可以了。(在SDK 4.2, 4.4.1上测试)

- (void) addFooter
{
    UIView *v = [[UIView alloc] initWithFrame:CGRectZero];

    [self.myTableView setTableFooterView:v];
}

或者更简单——在你设置tableview的地方,添加这一行:

//change height value if extra space is needed at the bottom.
[_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)]];

或者更简单——简单地删除任何分隔符:

[_tableView setTableFooterView:[UIView new]];

再次感谢wkw:)

我使用一个表视图来显示固定数量的固定高度行,所以我简单地调整了它的大小并使其不可滚动。

我只是在ViewDidLoad函数中添加了这一行,问题就解决了。

tableView.tableFooterView = [[UIView alloc] init]; 

Uitableview额外的分隔线隐藏额外的分隔线隐藏在swift 3.0

 self.tbltableView.tableFooterView = UIView(frame: .zero)

如果你在你的视图中有一个搜索栏(例如限制结果的数量),你还必须在shouldReloadTableForSearchString和shouldReloadTableForSearchScope中添加以下内容:

controller.searchResultsTable.footerView = [ [ UIView alloc ] initWithFrame:CGRectZero ];