I read the documentation . But I'm still not sure when I need to not install it in false
. In the code below, if I install it in false
I will not see the header at all. If I leave it as true
that, then everything is in order.
The following in the View debug hierarchy will generate a warning that " width and position are ambiguous."
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView()
header.translatesAutoresizingMaskIntoConstraints = false
header.backgroundColor = .orange
header.heightAnchor.constraint(equalToConstant: 10).isActive = true
return header
}
I thought that whenever I need to change something in the code, I have to set the translatesAutoresizingMaskIntoConstraints
value to false
.
Perhaps it would be more correct to say whether you need to remove all its restrictions, then set the value for it false
and then add what you like, in which case you will need to add restrictions for all four parties.
However, if you just need to save what the system provides you with, then it will be a tableView that controls its position and width, and then leave the value true
.
It is right?
Honey source
share