ios - iOS 7 上的自动布局崩溃,在 iOS 8 上运行良好

标签 ios objective-c xcode ios7 ios8

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

这是我的 Storyboard相关的东西:

enter image description here

enter image description here

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

有任何想法吗?

最佳答案

对于可能发生冲突的 x 位置,您有两组约束。尝试删除将尾随和导致 super View 的偏移量对齐的约束对或尾随和导致字幕标签的约束。

关于ios - iOS 7 上的自动布局崩溃,在 iOS 8 上运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25978589/

相关文章:

ios - NSOperationQueue 中的 NSOperation 未被执行

ios - 在 AppDelegate 中实例化 UINavigationController

ios - UICollectionView 中的自动布局约束发生变化

ios - iOS 的 BLE 外设名称不正确

objective-c - NSMutableArray 仅将对象添加为指针?

ios - Images.xcassets 中的 LaunchImage 与 Launchscreen.xib

ios - 如何在 iOS 9 swift 中正确显示 popover ArrowDirections

ios - 用于样式的 Objective-C 类别

xcode - 目标依赖与链接二进制文件与库

带有 openGL 的 Xcode 屏幕保护程序