iOS7上的自动布局崩溃,在iOS8上运行良好

时间:2014-09-22 16:14:18

标签: ios objective-c xcode ios7 ios8

我正在使用针对> iOS7的Xcode 6.1(Beta)构建应用。 我有一个原型单元格,在故事板中完成了所有约束。它在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.

这是我的故事板相关内容:

enter image description here

enter image description here

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

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

x位置有两组可能存在冲突的约束。尝试删除一对约束,这些约束将尾随和超级视图对齐,带有偏移量或尾随并导致字幕标签。

答案 1 :(得分:0)

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