我正在用数据填充 UITableView 并且工作正常。
但我的问题是,当 UITableView 的数据行数较少时,它会正确显示包含数据的行,但会显示空白。 例如:如果 tableview 有 1 行要显示,它会显示该行,然后在该行下面有空白,如空行。 我试过了
tableView.tableFooterView = UIView()
和
tableView.tableFooterView = UIView(frame: CGRectZero)
截图:
但两者都只是删除了单元格边框,而不是出现的额外空白。 请建议。提前致谢。
编辑:
选择按钮不是单元格的一部分。只是试图点击选择按钮,然后 UITableView 显示在它下面。 (就像 DropDown 一样)。 此外,使用默认 Tableview Cell 而不是自定义 TableView Cell
代码:
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cityList.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cityCellIdentifier, forIndexPath: indexPath) as UITableViewCell
let row = indexPath.row
cell.textLabel?.text = self.cityList[row].cityEn
print("CityName" + self.cityList[row].cityEn )
return cell
}
Storyboard截图
最佳答案
如果您不想要空单元格,请将 TableView 样式从 Plain 设置为 Grouped。
关于ios - 删除多余的单元格/行空格,而不会在 UITableView 上显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35556411/