我刚刚添加一个UIView作为子视图界面生成器(基本单一视图应用程序)上的主要UIView。 没有设置任何约束,我的子视图消失。子视图消失与自动布局
subview's frame = (0 0; 320 0);
这是为什么?
如果我尝试添加一些约束,如拖尾空间,前导空间,顶部空间和底部空间被修复,我的视图仍然消失。
我该如何解决这个问题?
谢谢。
为了澄清一点,我创建了一个测试项目(单视图应用程序),并在图像中添加了2个子视图到主视图。我没有更改任何默认约束。 而且您可以在图像的日志中看到错误。
日志:
**2013-01-19 17:16:02.435 Test[8871:c07] 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:0x106178c0 h=--- v=--- V:[UIWindow:0x9917040(480)]>",
"<NSLayoutConstraint:0x106159e0 UIView:0x991a5a0.bottom == UIWindow:0x9917040.bottom>",
"<NSLayoutConstraint:0x991ab00 V:|-(518)-[BottomView:0x9919c90] (Names: '|':UIView:0x991a5a0)>",
"<NSLayoutConstraint:0x10615960 V:|-(20)-[UIView:0x991a5a0] (Names: '|':UIWindow:0x9917040)>",
"<NSLayoutConstraint:0x991aa80 BottomView:0x9919c90.bottom == UIView:0x991a5a0.bottom>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x991aa80 BottomView:0x9919c90.bottom == UIView:0x991a5a0.bottom>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.**
约束:
而且,这里是在模拟器结果:
貌似高度有0点 –
是的,我知道,我只是不知道为什么它被设置为0。 –
你可以粘贴错误的文本,无法读取它那里。 –