私のheaderViewの幅は画面の幅に適応しません。 マイviewForHeaderInSection
機能:私はセクション内の行の隠れているので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の(または類似したもの)にセルを追加する必要があります。 私の意見では、いくつかの制約をプログラム的に「表示」する必要がありますが、どういうわけかわかりません。
私はここでのことを扱う別のアプローチに答えましたが、私はあなたの問題があると思います。ビューのサブビューとして 'cell'を追加していますが、代わりに' cell.contentView'を追加する必要があります。また、 'cell.constraints'の代わりに' cell.contentView.constraints'を使用します。 – farzadshbfn