I have this TabBarController in my app to which I've added an UIView on the very top of the TabBar. I did this because this view shows persistent data that I wanted to display in every view.
I initialized this using initWithFrame: and it is just where I wanted it to be.
Today I noticed that when the status bar increases in height (during a call or personal hotspot), that view moves towards the bottom. I tried to fix that by adding a constraint:
[[self view] addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[_myView]-(44)-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:NSDictionaryOfVariableBindings(_myView)]];
This way, I'd expect that myView would always be spaced by 44 pts from the bottom of the screen, however it does not happen.
The debugger shows:
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
NSAutoresizingMaskLayoutConstraintsthat you don't understand, refer to the documentation for theUIViewpropertytranslatesAutoresizingMaskIntoConstraints)( "< NSLayoutConstraint:0x165c0280 V:[UIView:0x165bda30]-(44)-| (Names: '|':UIView:0x166dd460 )>", "< NSAutoresizingMaskLayoutConstraint:0x165a7ce0 h=--& v=--& UIView:0x165bda30.midY == + 507>", "< NSAutoresizingMaskLayoutConstraint:0x165c50c0 h=--& v=--& V:[UIView:0x165bda30(34)]>", "< NSAutoresizingMaskLayoutConstraint:0x165c3a90 h=-&- v=-&- UIView:0x166dd460.height == UIWindow:0x1668f870.height - 20>", "< NSAutoresizingMaskLayoutConstraint:0x165a8070 h=--- v=--- V:[UIWindow:0x1668f870(568)]>" )Will attempt to recover by breaking constraint
< NSLayoutConstraint:0x165c0280 V:[UIView:0x165bda30]-(44)-| (Names: '|':UIView:0x166dd460 )>Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.
This error only shows when the status bar is extended. There are no other constraints added programmatically, and the Interface Builder's VC for this class is empty. Everything is added programmatically.
This is driving me nuts!