My app has only one view controller which needs landscape orientation and others will be in portrait. When I tried to make it landscape with code, I receive logs like this:
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.
(
<_UILayoutSupportConstraint:0x7fece31416f0 V:[_UILayoutGuide:0x7fece0dc94b0(64)]>,
<_UILayoutSupportConstraint:0x7fece0ddf0c0 V:|-(0)-[_UILayoutGuide:0x7fece0dc94b0] (Names: '|':UIView:0x7fece0dca270 )>,
<_UILayoutSupportConstraint:0x7fece3145cb0 V:[_UILayoutGuide:0x7fece3108140(0)]>,
<_UILayoutSupportConstraint:0x7fece31201c0 _UILayoutGuide:0x7fece3108140.bottom == UIView:0x7fece0dca270.bottom>,
<NSLayoutConstraint:0x7fece0de5700 V:[UIView:0x7fece3124110(280)]>,
<NSLayoutConstraint:0x7fece0dcf870 V:[UIButton:0x7fece3137790'开始训练'(42)]>,
<NSLayoutConstraint:0x7fece0dc4df0 V:[_UILayoutGuide:0x7fece0dc94b0]-(0)-[UIView:0x7fece3124110]>,
<NSLayoutConstraint:0x7fece0d42c60 V:[UIView:0x7fece3124110]-(0)-[UITableView:0x7fece112a000]>,
<NSLayoutConstraint:0x7fece0dec530 V:[UITableView:0x7fece112a000]-(0)-[UIButton:0x7fece3137790'开始训练']>,
<NSLayoutConstraint:0x7fece0df24c0 V:[UIButton:0x7fece3137790'开始训练']-(0)-[_UILayoutGuide:0x7fece3108140]>,
<NSLayoutConstraint:0x7fece3252110 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fece0dca270(320)]>,
)
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7fece0de5700 V:[UIView:0x7fece3124110(280)]>
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.
My constrains are very simple, no error appears without changing to landscape. Anybody ever met problems like this?