美文网首页
解决自适应 tableHeaderView 覆盖 cell 的问

解决自适应 tableHeaderView 覆盖 cell 的问

作者: 毛线sama | 来源:发表于2019-05-09 01:48 被阅读0次
  1. 使用代理方法返回 tableHeaderView 而不是直接设置
 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    return tableHeaderView
}
  1. 自动布局完后立即刷新画面并直接设置 tableHeaderView
tableView.layoutIfNeeded()
tableView.tableHeaderView = tableHeaderView
  1. 以上如果都不行可能是因为自动布局用了Snapkit的类似
xxView.height.equalTo(view).multipliedBy(0.3)

之类的写法,把上面改成equalTo(view.bounds.height * 0.3)就行了
(并不知道为啥

相关文章

网友评论

      本文标题:解决自适应 tableHeaderView 覆盖 cell 的问

      本文链接:https://www.haomeiwen.com/subject/ytxioqtx.html