简体   繁体   English

Xcode 6对不同大小的约束

[英]Xcode 6 constraints on different sizes

I'm doing an iPhone app using Xcode 6 My problem here is, I add a constraint to an image, and all is fine, and than I try to add another constraint on a smaller screen and I get the error on the bottom of this message. 我正在使用Xcode 6做一个iPhone应用程序。我的问题是,我向图像添加了一个约束,一切都很好,然后我尝试在较小的屏幕上添加另一个约束,但我得到了下面这个错误。信息。 Is there any way of adding different constraints according to the size we are at? 有什么方法可以根据我们所处的规模来添加不同的约束? That is what it feels like on Xcode on the wAny hAny area, but for some reason it just doesn't work. 那就是在whny hAny区域的Xcode上的感觉,但是由于某种原因,它根本不起作用。

2014-10-06 17:41:45.059 testapp[2623:26567] Unable to simultaneously satisfy constraints. 2014-10-06 17:41:45.059 testapp [2623:26567]无法同时满足约束。 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; 尝试以下操作:(1)查看每个约束,并尝试找出不期望的约束; (2) find the code that added the unwanted constraint or constraints and fix it. (2)查找添加了一个或多个不必要约束的代码并进行修复。 (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "", "", "" ) (注意:如果看到的是您不了解的NSAutoresizingMaskLayoutConstraints,请参阅有关UIView属性translationsAutoresizingMaskIntoConstraints的文档)(“”,“”,“”,“”)

Will attempt to recover by breaking constraint 将尝试通过打破约束来恢复

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 在UIViewAlertForUnsatisfiableConstraints上创建一个符号断点,以在调试器中捕获该断点。 The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 列出的UIView的UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

When a constraint receives a negative value or the value that contradicts with other values, it spits an error. 当约束接收到负值或与其他值相矛盾的值时,它将抛出错误。 For instance: 例如:

  • You have an image, that has height 500 and the constraint attached to it's bottom 您有一个图像,其高度为500,底部附加了约束
  • You modify this constraint such a way that the image gets smaller and smaller (constant value) 修改此约束,使图像变得越来越小(恒定值)
  • Eventually image will have negative value, which is impossible. 最终图像将具有负值,这是不可能的。 And the rest of the constraints will also "suffer" 其余的约束也将“遭受痛苦”

Make sure that the height of the parent view is greater than the height of the image. 确保父视图的高度大于图像的高度。 Hopefully the example above will make you better understand the issue in general. 希望上面的示例可以使您更好地理解该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM