【发布时间】:2017-02-17 12:11:45
【问题描述】:
我有一个为 iPad 启用旋转的应用程序(iPhone 版本是无旋转的)。在我的设计中,在故事板中,我有这个层次结构:UIView - UIScrollView - UIView。所有“视图”都设置为具有整个屏幕宽度。第二个UIView 的类设置为MyView,这是一个带有外部xib 文件的类。 Storyboard 和 xib 都是以纵向模式创建的。
现在解决问题。
如果我以横向模式运行应用程序,则一切正常。如果我旋转 应用之后,一切正常。
-
如果我在纵向模式下运行应用程序,设计就会“中断”。整个内容更薄(所以
MyView的结尾和屏幕的结尾之间大约有 100+ px 的间隙)。如果我旋转应用程序,设计仍然损坏但正确“放大”。差距仍然是相同的大小。在第一次启动期间,我在调试器中收到以下错误: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) ( "<NSAutoresizingMaskLayoutConstraint:0x1545b7800 h=-&- v=-&- UIView:0x1546a8cb0.width == ScrollableContentView:0x154575da0.width - 232>", "<NSLayoutConstraint:0x15458dd80 H:[UIActivityIndicatorView:0x1546afa60]-(370)-| (Names: '|':UIView:0x1546ab840 )>", "<NSLayoutConstraint:0x15458ddd0 H:|-(361)-[UIActivityIndicatorView:0x1546afa60] (Names: '|':UIView:0x1546ab840 )>", "<NSLayoutConstraint:0x1546c7080 H:[UIView:0x1546ab840]-(0)-| (Names: '|':UIView:0x1546a8cb0 )>", "<NSLayoutConstraint:0x1546c7120 H:|-(0)-[UIView:0x1546ab840] (Names: '|':UIView:0x1546a8cb0 )>", "<NSLayoutConstraint:0x154579710 H:|-(0)-[ScrollableContentView:0x154575da0] (Names: '|':UIScrollView:0x15504c000 )>", "<NSLayoutConstraint:0x154686ef0 UIScrollView:0x15504c000.centerX == ScrollableContentView:0x154575da0.centerX>", "<NSLayoutConstraint:0x154697cc0 H:[UIScrollView:0x15504c000]-(0)-| (Names: '|':UIView:0x154547b80 )>", "<NSLayoutConstraint:0x154697d10 H:|-(0)-[UIScrollView:0x15504c000] (Names: '|':UIView:0x154547b80 )>", "<NSLayoutConstraint:0x15463b8c0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x154547b80(768)]>" ) Will attempt to recover by breaking constraint
无论我做什么,我都无法消除这个问题。即使我删除了几乎所有约束,我仍然有同样的问题。
【问题讨论】:
标签: ios objective-c uiview storyboard nslayoutconstraint