Though not consequential it is quite annoying to see these warnings:
Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) (
"<NSLayoutConstraint:0x19288a20 V:|-(6)-[UILabel:0x19288640] (Names: '|':_UITableViewHeaderFooterContentView:0x192885b0 )>",
"<NSLayoutConstraint:0x19288a70 V:[UILabel:0x19288640]-(6)-| (Names: '|':_UITableViewHeaderFooterContentView:0x192885b0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x19289cd0 h=--& v=--& V:[_UITableViewHeaderFooterContentView:0x192885b0(0)]>" )
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x19288a70 V:[UILabel:0x19288640]-(6)-| (Names: '|':_UITableViewHeaderFooterContentView:0x192885b0 )>
There is nothing wrong of my constraints. The issue occurs when UIKit tries to do layout for the UITableViewHeaderFooterView
with these constraints when the view is initially of zero size. Of course it is impossible to satisfy any constraints with any positive metrics.
One obvious workaround is to set a lower-than-UILayoutPriorityRequired
priority or use NSLayoutRelationLessThanOrEqual
instead of NSLayoutRelationEqual
for each positive metrics. But then I need to add these crutches to all of my constraints on all of my views. Not to mention that what I really want are hard and fast not optional constraints.
Another workaround is to set a initial frame for UITableViewHeaderFooterView
. But considering its designate init method is -initWithReuseIdentifier:
not -initWithFrame:
and it is the responsibility of UITableView
and UITableViewDelegate
to specify frame for UITableViewHeaderFooterView
, it neither feels a good workaround.
So any better ones?