2014-02-20 133 views
1

我有一些自动布局的问题。一切变得所示正确的,一切工作正常,但我得到的命令行一些警告信息:Autolayout显示警告消息

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:0xb6a60f0 H:[UIImageView:0xb645e40(75)]>", 
"<NSLayoutConstraint:0xb6d0e90 H:[UIView:0xb6c7350(220)]>", 
"<NSLayoutConstraint:0xb6aaea0 H:|-(10)-[UIImageView:0xb645e40] (Names: '|':UITableViewCellContentView:0xb6c1590)>", 
"<NSLayoutConstraint:0xb6c85c0 H:[UIView:0xb6c7350]-(7)-| (Names: '|':UITableViewCellContentView:0xb6c1590)>", 
"<NSLayoutConstraint:0xb6d2270 H:[UIImageView:0xb645e40]-(8)-[UIView:0xb6c7350]>", 
"<NSAutoresizingMaskLayoutConstraint:0xb6abd20 h=--& v=--& H:[UITableViewCellContentView:0xb6c1590(300)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0xb6d0e90 H:[UIView:0xb6c7350(220)]> 

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

正如你可以看到它的一个TableViewCell我使用一个视图(示例文本)与TextView(用于iOS7)和AttributedTextView(用于iOS6)!

最新问题?

回答

2

问题是你有冲突的限制...自动布局可能是一个痛苦....有时。 当这种情况发生在我身上时,我通常会清除所有约束,并通过选择清除所有约束来重新开始。

之后,您也可以选择“添加缺少的约束条件”,并希望XCode会自动知道您想要做什么。实际上,XCode会让它正确无误。

从你的屏幕截图中可以看出你有太多的约束,所以另一个选择是尝试一个接一个地去除,并捕捉那些“冲突”的约束。

clearing constraints

+0

感谢您的提示,我会尽力删除每一个约束...... – Davis

+0

我个人不喜欢使用“添加缺少约束”选项。它相当难以预测,相反你应该调试出错的地方并自己清除它。如果X-Code拧紧,可以节省很多时间。 – footyapps27

+0

@ footyapps27,一般来说,你是对的。但是,如果你正在治疗约束 - 添加缺失的约束是一个快速的解决方案。 – Raz

0

集对于每个视图translatesAutoresizingMaskIntoConstraints = NO;这就是他想要告诉你的。在运行期间你有你的约束和通用的。猜测我们会看到这个属性在iOS版本中默认切换为NO。

+0

感谢您的回复,遗憾的是没有任何改变。我做了:self.attributedTextView.translatesAutoresizingMaskIntoConstraints = NO;和self.messageTextView.translatesAutoresizingMaskIntoConstraints = NO; – Davis

+0

这是内容视图有冲突:NSAutoresizingMaskLayoutConstraint:0xb6abd20 h = - &v = - &H:[UITableViewCellContentView:0xb6c1590(300)]>“ –