2014-03-28 105 views
0

我想要做一个纯自动布局约束的应用程序,没有自动调整,并且在我的故事板中打开Xcode 5文件中的“Use Auto Layout”故事板的属性,但我仍然收到异常。我不打开代码中任何位置的translatesAutoresizingMaskIntoConstraints。这是我的理解,如果自动布局打开IB将禁用translatesAutoresizingMaskIntoConstraints。有任何想法吗?在故事板上启用了自动布局,但我仍然收到AutolayoutMaskContraints

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:0xdca62c0 V:[_UILayoutGuide:0xdca7310]-(201)-[UIView:0xcc69170]>", 
    "<NSLayoutConstraint:0xdca63e0 V:[UIView:0xcc69170]-(112)-[_UILayoutGuide:0xdc51f50]>", 
    "<_UILayoutSupportConstraint:0xdc581e0 V:[_UILayoutGuide:0xdca7310(52)]>", 
    "<_UILayoutSupportConstraint:0xdc97780 V:|-(0)-[_UILayoutGuide:0xdca7310] (Names: '|':UIView:0xdca7240)>", 
    "<_UILayoutSupportConstraint:0xdc7e3b0 V:[_UILayoutGuide:0xdc51f50(32)]>", 
    "<_UILayoutSupportConstraint:0xdc7df20 _UILayoutGuide:0xdc51f50.bottom == UIView:0xdca7240.bottom>", 
    "<NSAutoresizingMaskLayoutConstraint:0xdcce0c0 h=--& v=--& V:[UIView:0xdca7240(320)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0xdca62c0 V:[_UILayoutGuide:0xdca7310]-(201)-[UIView:0xcc69170]> 

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. 
+1

是以编程方式创建的视图0xdca7240?对于以编程方式创建的视图,'translatesAutoresizingMaskIntoConstraints'默认为'YES'。 –

+1

**大多数**视图在自动布局开启的情况下在IB中创建时,会将'translatesAutoresizingMaskIntoConstraints'设置为'NO',例如,容器视图不会。 (或者说,嵌入式视图将成为容器视图。) –

+0

感谢Scott和Timothy。这一天几乎浪费了一天,但我的回答是我确定的。 – possen

回答

0

看来,对于一个视图根视图控制器具有translatesAutoresizingMaskIntoConstraints打开所有的时间。你可以在故事板文件的xml中看到这个。但是,所有子视图都已关闭translatesAutoresizingMaskIntoConstraints。我怀疑这是正常的行为,但如果你期望没有翻译发生,有点混乱。

相关问题