presentingViewController 是不是与presentingViewController 一起旋转
Posted
技术标签:
【中文标题】presentingViewController 是不是与presentingViewController 一起旋转【英文标题】:Does presentingViewController rotate with presentedViewControllerpresentingViewController 是否与presentingViewController 一起旋转 【发布时间】:2015-08-03 16:03:08 【问题描述】:我的项目设置支持纵向和横向。但是,我只希望一个呈现的视图控制器(比如视图控制器 A)能够旋转。我用
override func shouldAutorotate() -> Bool
return false
override func supportedInterfaceOrientations() -> Int
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
在其他视图控制器中禁用旋转。有用。但是,当 A 以模态方式呈现并旋转时,呈现的视图控制器(比如视图控制器 B)会报告:
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.
我在 B 中使用自动布局,我不希望它被旋转。我做了一些实验,这些约束错误与旋转时的错误完全相同。我怀疑 B 也被旋转了,尽管它是不可见的。
我被这个问题困扰了几天。我真的很想知道为什么会发生这种情况以及如何解决这个问题?
【问题讨论】:
【参考方案1】:也许this 的回答可能会对你有所帮助。
引文(答案的第4段):
[...] 解决方案是两个
UIWindow
堆叠在一起,每个都使用自己的根视图控制器旋转(或不旋转)。 [...]
(注:第 3 段包含解释的主要信息)。
希望这会有所帮助。
【讨论】:
以上是关于presentingViewController 是不是与presentingViewController 一起旋转的主要内容,如果未能解决你的问题,请参考以下文章
presentingViewController 总是得到 UITabBarController
presentingViewController 显示为 null
为啥解散presentingViewController,只解散子控制器?