我有一个包含许多部分的表格 View 。我正在使用一个实际的 tableview 单元格,我将其出队用作自定义节标题。我遇到的问题是当我将节标题“粘”到表格顶部直到出现下一个节时。
我怎样才能防止这种情况发生并让它像往常一样向上滚动?
这是我的代码
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "headerCell") as! HeaderTableViewCell
return cell
}
return UIView()
}
最佳答案
执行以下步骤。
来自@IB
- 选择你的tableView
- 转到属性检查器
- 查找默认为
Plain
的样式属性下拉列表 - 将其更改为
Grouped
或者,如果您以编程方式创建 TableView,请使用
let tableView = UITableView(frame: YourFrame, style: .Grouped)
关于ios - 如何防止tableview section head在滚动时粘住?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47359936/