在故事板上启用了自动布局,但我仍然获得了AutolayoutMaskContraints

时间:2014-03-28 01:38:11

标签: ios xcode autolayout xcode-storyboard

我正在尝试基于纯自动布局约束的应用程序,没有自动调整,并且在我的故事板中,我打开了标记"使用自动布局"在故事板的Xcode 5文件属性中,我仍然得到例外。我没有在代码中的任何地方启用translatesAutoresizingMaskIntoConstraints。据我所知,如果打开自动布局,IB将禁用translatesAutoresizingMaskIntoConstraints。有任何想法吗?

    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 个答案:

答案 0 :(得分:0)

似乎视图的根视图控制器始终打开translatesAutoresizingMaskIntoConstraints。您可以在storyboard文件的xml中看到这一点。但是,所有子视图都关闭了translatesAutoresizingMaskIntoConstraints。我怀疑这是正常的行为,但如果您不希望发生翻译,则会有点混乱。