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

如何移除这些单元格?


当前回答

iOS 7+使用故事板

简单地拖一个UIView到你的UITableView作为页脚。设置页脚视图的高度为0。

其他回答

为了以编程方式消除UItableview底部额外的分隔行,只需写下下面两行代码,它就会从UItableview底部删除额外的分隔行。

tableView.sectionFooterHeight = 0.f;
tableView.sectionHeaderHeight = 0.f;

这招对我一直很管用,你自己试试。

Swift适用于:

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];
}

在Swift中移除UITableView中空行的额外分隔行

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    self.yourTableview.tableFooterView = UIView()
}

当tableView有tableFooterView时UIKit不会创建空单元格。我们可以做个小技巧分配一个零高度的UIView对象作为tableView的页脚。

tableView.tableFooterView = UIView()