【发布时间】:2014-11-04 10:24:00
【问题描述】:
我正在尝试将 UILabel 固定到它的父单元格。我添加了四个约束(顶部、前导、尾随、底部)在 iOS 8.0 上运行良好,但在 iOS 7.X 上却不行。请看下图:
我做错了什么?请指教!
编辑#1
它似乎是自 Xcode 6 GM 以来才被破坏的。我的方法在 Xcode 6 beta 7 中运行良好。
此外,如果我减小内部视图的宽度,它会引发以下警告:
2014-09-10 19:58:28.109 Test[57827:60b] 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:0x799573a0 H:|-(8)-[UIView:0x798a86e0] (Names: '|':UIView:0x798ae5d0 )>",
"<NSLayoutConstraint:0x799573d0 H:[UIView:0x798a86e0]-(43)-| (Names: '|':UIView:0x798ae5d0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x798a8b00 h=--& v=--& H:[UIView:0x798ae5d0(50)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x799573d0 H:[UIView:0x798a86e0]-(43)-| (Names: '|':UIView:0x798ae5d0 )>
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.
【问题讨论】:
-
尝试将UILabel的宽高设置为容器。
-
我该怎么做?它已禁用(灰显)
-
Ctrl + 从 UILabel 拖动到容器,然后选择等宽和等高。您必须分两步完成。
-
我没有这个选项!只有这些...i.imgur.com/NTVwcOC.png
-
我遇到了完全相同的问题。它曾经在 iOS7 的 Xcode 6 Beta 7 上工作,但现在在 iOS7 上的 XCode 6 GM 上工作,没有遵守限制。
标签: ios iphone uicollectionview autolayout uicollectionviewcell