无法同时满足约束 - 没有适当的约束 [英] Unable to simultaneously satisfy constraints - No constraints in place

查看:22
本文介绍了无法同时满足约束 - 没有适当的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成并删除了每个用户约束,但在旋转设备后我仍然收到以下错误.我完全不知道为什么.有人有什么想法吗?

I have gone through and removed every single user constraint yet I am still getting the following error ONLY after I rotate the device. I have absolutely no clue why though. Does anyone have any ideas?

2013-01-14 21:30:31.363 myApp[35869:c07] 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) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=--& v=--& V:[UIView:0xa330270(768)]>",
    "<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-|   (Names: '|':UIView:0xa330270 )>",
    "<NSLayoutConstraint:0xa338390 V:|-(841)-[UIView:0xa331260]   (Names: '|':UIView:0xa330270 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-|   (Names: '|':UIView:0xa330270 )>

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.

推荐答案

我们来一一看看.

"<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=--& v=--& V:[UIView:0xa330270(768)]>"

这是说视图 0xa330270 (A) 必须是 768 点高.

This is saying view 0xa330270 (A) must be 768 points high.

"<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-| (Names: '|':UIView:0xa330270 )>"

这是说视图 0xa331260 (B) 的底部边缘必须与 A 的底部有 -1 的间隙,这是它的超级视图.

This is saying view 0xa331260 (B)'s bottom edge must be a gap of -1 from the bottom of A, which is it's superview.

""

这就是说B的顶部边缘与其父视图A的顶部必须相距841点.

This is saying that B's top edge must be a gap of 841 points from the top of its superview, A.

这三件事不可能都是真的 - A 不能高 768 点,并且包含一个子视图,其顶部边缘距顶部插入 841 点,距顶部插入 -1 点底部.你在哪里定义了这些约束?

These three things can't all be true - A can't be 768 points high, and contain a subview with a top edge 841 points inset from the top and -1 points inset from the bottom. Where have you defined each of these constraints?

您还没有说明您要实现的布局,但看起来您的超级视图上可能有一个自动调整大小的蒙版,可以防止它在旋转设备时改变高度.据我所知,仅当您以编程方式添加视图时才会出现自动调整大小约束,因为故事板或 xib 要么是全自动布局,要么不是.除非您正在执行诸如将自动布局视图(从笔尖加载?)添加到非自动布局笔尖的另一个视图之类的事情?

You haven't said what layout you are trying to achieve, but it looks like you might have an autoresizing mask on the superview that is preventing it changing in height when you rotate the device. As far as I know the autoresizing constraints only appear if you have added views programmatically, since a storyboard or xib is either all-autolayout, or not. Unless you are doing something like adding an auto laid out view (loaded from a nib?) to another view from a non-autolayout nib?

这篇关于无法同时满足约束 - 没有适当的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆