I want to use different layout on landscape and portrait,
but always got warning about it.
my solution:
Add general constraint :
View A Left = SuperView Left
View A Top = SuperView Top
View A Bottom = SuperView Bottom
View B Right = SuperView Right
View B Top = SuperView Top
View B Bottom = SuperView Bottom
View B Left = View A Right
Add landscape constraint :
View A width = superview Height + 30
Add portrait constraint :
View A width = superView width
Then,
In willRotateToInterfaceOrientation:duration:
call [self.view setNeedsUpdateConstraints];
In updateViewConstraints
set constraint active YES to landscape/portrait and also set NO to another constraint.
when I run the app, it workable, bur I got some warning:
UITableView = View A,
UIView (0x13ed098c0) = superView
UIView (0x174287080) = View B
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:0x174287030 'UIView-Encapsulated-Layout-Width' H:[UIView:0x13ed098c0(568)]>",
"<NSLayoutConstraint:0x174287080 'UIView-Encapsulated-Layout-Height' V:[UIView:0x13ed098c0(239)]>",
"<NSLayoutConstraint:0x17428a960 UITableView:0x13f0b2000.width == UIView:0x13ed098c0.width>",
"<NSLayoutConstraint:0x170284dd0 UITableView:0x13f0b2000.width == UIView:0x13ed098c0.height + 30>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x174287080 'UIView-Encapsulated-Layout-Height' V:[UIView:0x13ed098c0(239)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
How can I make it work without warning?
Thanks,