两个非冲突的约束创建NSLayoutConstraint错误 [英] Two non-conflicting constraints creating a NSLayoutConstraint error
本文介绍了两个非冲突的约束创建NSLayoutConstraint错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UILabel两个约束牵制的铅和尾部的上海华。
I have two constraints on a UILabel pinning the lead and the tail to the superview.
问题是,当我打开应用中的观点,我得到这个错误:
The problem is, when I open the view in the app, I get this error:
2015-04-11 22:00:24.319 TradingPost[7610: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:0x17e9da10 H:[UILabel:0x17ef3ca0]-(12)-| (Names: '|':UITableViewCellContentView:0x17eaceb0 )>",
"<NSLayoutConstraint:0x17e9da40 H:|-(88)-[UILabel:0x17ef3ca0] (Names: '|':UITableViewCellContentView:0x17eaceb0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x17eb1b00 h=--& v=--& H:[UITableViewCellContentView:0x17eaceb0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17e9da10 H:[UILabel:0x17ef3ca0]-(12)-| (Names: '|':UITableViewCellContentView:0x17eaceb0 )>
然后,它前进到充当如果所有的约束用预期功能的工作。
It then proceeds to function as if all of the constraints were working with intended functionality.
下面是我的约束清晰的截图:
Here's a screenshot of my constraints for clarity:
推荐答案
我居兴你正在使用一个UITableView和创建自定义单元格。结果
创建的UITableViewCell的子类,这个类分配给您的自定义单元格并覆盖 awakeFromNib
如下:
I am gussing you are using a UITableView and creating a custom cell.
Create a subclass of UITableViewCell, assign that class to your custom cell and overwrite the awakeFromNib
as follows:
- (void)awakeFromNib {
[super awakeFromNib];
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
这篇关于两个非冲突的约束创建NSLayoutConstraint错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文