Xcode约束错误消息

时间:2013-12-04 19:17:07

标签: ios iphone objective-c ipad

任何人都可以帮助我在运行时理解来自xcode的错误消息:

 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:0x1b886330 H:[UILabel:0x1b885ed0]-(8)-|   (Names: '|':UITableViewCellContentView:0x1b885980 )>",
     "<NSLayoutConstraint:0x1b886360 H:|-(8)-[UILabel:0x1b885ed0]   (Names: '|':UITableViewCellContentView:0x1b885980 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x1b87e8c0 h=--& v=--& H:[UITableViewCellContentView:0x1b885980(0)]>"
 )

 Will attempt to recover by breaking constraint 
 <NSLayoutConstraint:0x1b886330 H:[UILabel:0x1b885ed0]-(8)-|   (Names: '|':UITableViewCellContentView:0x1b885980 )>

提前致谢。

3 个答案:

答案 0 :(得分:0)

不要尝试一起使用自动调整大小和约束;你会度过一段美好的时光。如错误所示,请参阅translatesAutoresizingMaskIntoConstraints上的文档。您可能希望在视图中将其设置为NO

答案 1 :(得分:0)

查看Apple在AutoLayout上的WWDC 2012视频,特别是有关视觉语言的部分:

Introduction to Auto layout

Auto layout By Example

Mastering Auto layout

WWDC 2013中还有一个关于如何在XCode 5中使用自动布局的Autolayout视频。

答案 2 :(得分:0)

这个有点奇怪:H:[UITableViewCellContentView:0x1b885980(0)]

我可能会弄错,但这不是说单元格内容视图的宽度是零吗?怎么可能?有谁知道为什么会发生这种情况?我自己也看到了类似的问题,细胞的宽度为零......