0

My project setting supports both portrait and landscape orientation. However, I only want one presented view controller (say view controller A) to be able to rotate. I use

override func shouldAutorotate() -> Bool {
    return false
}

override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}

to disable rotation in other view controllers. It works. However, when A is presented modally and rotated, the presenting view controller (say view controller B) reports:

2015-08-03 23:34:06.000 Adjimu[4161:181458] 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:0x7ff055858cd0 V:[UIView:0x7ff055858aa0(1)]>",
    "<NSLayoutConstraint:0x7ff055856610 UIScrollView:0x7ff055855e20.width == 1.77778*UIScrollView:0x7ff055855e20.height>",
    "<NSLayoutConstraint:0x7ff05585a180 H:|-(0)-[UIScrollView:0x7ff055855e20]   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a1d0 V:|-(0)-[UIScrollView:0x7ff055855e20]   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a220 H:[UIScrollView:0x7ff055855e20]-(0)-|   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a310 V:[UIScrollView:0x7ff055855e20]-(10)-[UILabel:0x7ff05584ea40'Every Child Needs a Famil...']>",
    "<NSLayoutConstraint:0x7ff05585a400 V:[UILabel:0x7ff05584ea40'Every Child Needs a Famil...']-(5)-[UIButton:0x7ff055846200]>",
    "<NSLayoutConstraint:0x7ff05585a720 V:[UIButton:0x7ff055846200]-(5)-[UIView:0x7ff055858aa0]>",
    "<NSLayoutConstraint:0x7ff05585a810 V:[UIView:0x7ff055858aa0]-(0)-[UITableView:0x7ff05603c800]>",
    "<NSLayoutConstraint:0x7ff05585a860 V:[UITableView:0x7ff05603c800]-(0)-[_UILayoutGuide:0x7ff0558599f0]>",
    "<_UILayoutSupportConstraint:0x7ff053dc5570 V:[_UILayoutGuide:0x7ff0558599f0(0)]>",
    "<_UILayoutSupportConstraint:0x7ff053db64f0 _UILayoutGuide:0x7ff0558599f0.bottom == UIView:0x7ff055858970.bottom>",
    "<NSLayoutConstraint:0x7ff05585eac0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7ff055858970(667)]>",
    "<NSLayoutConstraint:0x7ff05585eb10 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7ff055858970(262)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7ff055858cd0 V:[UIView:0x7ff055858aa0(1)]>

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.
2015-08-03 23:34:06.002 Adjimu[4161:181458] 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:0x7ff055856610 UIScrollView:0x7ff055855e20.width == 1.77778*UIScrollView:0x7ff055855e20.height>",
    "<NSLayoutConstraint:0x7ff05585a180 H:|-(0)-[UIScrollView:0x7ff055855e20]   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a1d0 V:|-(0)-[UIScrollView:0x7ff055855e20]   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a220 H:[UIScrollView:0x7ff055855e20]-(0)-|   (Names: '|':UIView:0x7ff055858970 )>",
    "<NSLayoutConstraint:0x7ff05585a310 V:[UIScrollView:0x7ff055855e20]-(10)-[UILabel:0x7ff05584ea40'Every Child Needs a Famil...']>",
    "<NSLayoutConstraint:0x7ff05585a400 V:[UILabel:0x7ff05584ea40'Every Child Needs a Famil...']-(5)-[UIButton:0x7ff055846200]>",
    "<NSLayoutConstraint:0x7ff05585a720 V:[UIButton:0x7ff055846200]-(5)-[UIView:0x7ff055858aa0]>",
    "<NSLayoutConstraint:0x7ff05585a810 V:[UIView:0x7ff055858aa0]-(0)-[UITableView:0x7ff05603c800]>",
    "<NSLayoutConstraint:0x7ff05585a860 V:[UITableView:0x7ff05603c800]-(0)-[_UILayoutGuide:0x7ff0558599f0]>",
    "<_UILayoutSupportConstraint:0x7ff053dc5570 V:[_UILayoutGuide:0x7ff0558599f0(0)]>",
    "<_UILayoutSupportConstraint:0x7ff053db64f0 _UILayoutGuide:0x7ff0558599f0.bottom == UIView:0x7ff055858970.bottom>",
    "<NSLayoutConstraint:0x7ff05585eac0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7ff055858970(667)]>",
    "<NSLayoutConstraint:0x7ff05585eb10 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7ff055858970(262)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7ff055856610 UIScrollView:0x7ff055855e20.width == 1.77778*UIScrollView:0x7ff055855e20.height>

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.

I use auto layout in B and I don't want it to be rotated. I did some experiments and these constraint errors are exactly the same errors as when it was rotated. I suspect that B is rotated as well although it is invisible.

I was haunted by this problem for a few days. I really want to know why this happened and how to solve this problem?

Chao Wang
  • 398
  • 1
  • 4
  • 11

1 Answers1

0

Perhaps this answer might help you out.

Quotation (4th paragraph of the answer):

[...] The solution is two UIWindow stacked on top of each other, each rotating (or not) with its own root view controller. [...]

(Note: 3rd paragraph contains the main message of the explanation).

Hope this helps.

Community
  • 1
  • 1
anneblue
  • 706
  • 4
  • 21