Pet*_*Pik 1 uitableview tableview ios swift
我正在尝试在我的UITableView headerView上应用一个大小,但似乎第一个节头总是比其余部分headerViews小一点.我已经说过UITableView的约束所以应该没问题.为什么第一部分更小?

func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return ""
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 20
}
Run Code Online (Sandbox Code Playgroud)
使用分组UITableView时会出现此问题.对于第一个节标题,节标题高度显示较短,因为它上面没有页脚.但是,第一个之后的每个节标题都有一个直接位于其上方的页脚.页脚具有默认高度,这有助于节标题的整体高度外观.因此,设置截面页脚高度,使组截面之间的空间具有相同的视觉高度.
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.min
}
Run Code Online (Sandbox Code Playgroud)
我们使用CGFloat.min而不是0,因为返回0将导致页脚返回默认高度.
| 归档时间: |
|
| 查看次数: |
673 次 |
| 最近记录: |