【发布时间】:2016-04-18 17:57:55
【问题描述】:
我的 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(或类似的东西),因为我在该部分中隐藏了行。 在我看来,我必须以编程方式添加“查看”一些约束,但我不知道如何
【问题讨论】:
-
我在这里回答了另一种处理方法,但我认为你的问题是;您正在添加
cell作为视图的子视图,但您必须添加cell.contentView代替。并且也代替cell.constraints,使用cell.contentView.constraints
标签: ios uitableview swift2.2