我的 headerView 的宽度不适应屏幕的宽度。我的viewForHeaderInSection
功能:
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = self.tableView.dequeueReusableCellWithIdentifier("sectionCell") as! sectionCell
cell.hint.text = "some name"
cell.tag = section
let singleTap = UITapGestureRecognizer(target: self, action: #selector(singleTapOnSection(_:)))
cell.addGestureRecognizer(singleTap)
let view = UIView(frame: cell.frame)
view.addConstraints(cell.constraints)
view.addSubview(cell)
return view
}
我必须将单元格添加到 UIView (或类似的东西),因为我在该部分中隐藏了行。在我看来,我必须以编程方式添加“查看”一些约束,但我不知道如何