【问题标题】:Auto layout crash on iOS7, works great on iOS8iOS7 上的自动布局崩溃,在 iOS8 上运行良好
【发布时间】:2014-11-16 16:26:52
【问题描述】:

我正在使用 Xcode 6.1 (Beta) 构建一个针对 >iOS7 的应用程序。 我有一个原型单元,所有约束都在情节提要中完成。它在 iOS8(iPhone 6 模拟器)上运行良好,当我在 iOS7(iPhone 5S 模拟器)上运行时,它崩溃并出现以下错误:

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) 
(
"<NSLayoutConstraint:0x7f901848bf00 UILabel:0x7f90190cb410.trailing == UILabel:0x7f90190c8110.trailing>",
"<NSLayoutConstraint:0x7f901848bf50 H:[UILabel:0x7f90190cb410]-(19)-|   (Names: '|':UITableViewCellContentView:0x7f9019076440 )>",
"<NSLayoutConstraint:0x7f901848bfa0 UILabel:0x7f90190cb410.leading == UILabel:0x7f90190c8110.leading>",
"<NSLayoutConstraint:0x7f9018490900 H:|-(15)-[UILabel:0x7f90190cb410]   (Names: '|':UITableViewCellContentView:0x7f9019076440 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7f90184a7800 h=--& v=--& H:[UITableViewCellContentView:0x7f9019076440(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f901848bf00 UILabel:0x7f90190cb410.trailing == UILabel:0x7f90190c8110.trailing>

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.

这是我的故事板相关的东西:

我为约束尝试了许多不同的方法,每次我告诉标签它从哪里开始(前导约束)和它在哪里结束(尾随...)时,它们都会崩溃。而且我不想给出明确的高度......

有什么想法吗?

【问题讨论】:

    标签: ios objective-c xcode ios7 ios8


    【解决方案1】:

    对于 x 位置,您有两组可能存在冲突的约束。尝试删除将尾随和通向超级视图的一对约束与偏移量或尾随和通向字幕标签对齐。

    【讨论】:

      【解决方案2】:

      当您的单元格太小时,您的约束可能会发生冲突。在界面生成器中,将单元格调整为非常小,看看它是否会产生错误。如果是这样,您需要确保您的单元格大小设置正确

      【讨论】:

        猜你喜欢
        • 2015-09-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-23
        • 1970-01-01
        • 1970-01-01
        • 2016-01-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多