【问题标题】:coming the issues of auto layouts in the console控制台中出现自动布局的问题
【发布时间】:2014-12-23 11:15:34
【问题描述】:

我正在尝试自动布局概念,这里我在控制台中遇到了更多问题,谁能告诉我如何解决这个问题

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:0x7faeb358e200 H:|-(0)-[UIImageView:0x7faeb35834b0]   (Names: '|':UIView:0x7faeb35832c0 )>",
    "<NSLayoutConstraint:0x7faeb358e390 UILabel:0x7faeb358a1e0'Welcome to'.leading == UIView:0x7faeb35832c0.leadingMargin + 46>",
    "<NSLayoutConstraint:0x7faeb358e4d0 UIImageView:0x7faeb3585ab0.leading == UILabel:0x7faeb358a1e0'Welcome to'.leading + 28>",
    "<NSLayoutConstraint:0x7faeb358e520 UIImageView:0x7faeb3585ab0.leading == UIImageView:0x7faeb35834b0.leading + 90>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7faeb358e390 UILabel:0x7faeb358a1e0'Welcome to'.leading == UIView:0x7faeb35832c0.leadingMargin + 46>

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.
2014-12-23 16:30:57.326 Aaja[11268:148329] Unable to simultaneously satisfy constraints.

这个问题反复出现 10 次

【问题讨论】:

    标签: ios ios8 xcode6 autolayout


    【解决方案1】:

    你有这个错误......

    |[ImageView-b0]
    
    |-46-[Label-e0]
    
    -(+28)-[ImageView-b0]
    [Label-e0]
    i.e. |-74-[ImageView-b0] //this conflicts the first one.
    
    [ImageView-b0]
    -(+90)-[ImageView-b0]
    

    这些是错误中显示的不同约束。

    看起来有点乱。图像视图和超级视图之间的间距为零。然后标签和超级视图之间有 46 个间距。

    但随后您尝试将标签和图像视图的左边缘对齐,相差 28。

    然后你还有一个我不太明白的问题。您是在告诉它将图像视图的前沿与自身对齐,但有所不同。这将永远无法工作。

    它基本上告诉你它不能使所有的约束都起作用,因为它们相互冲突,所以它必须打破其中的一些。

    【讨论】:

    • 如何解决这个问题,我对自动布局很困惑
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多