有谁有任何关于如何解决这个问题的线索吗?我试着按照他们的建议去做,但是我做的任何事情都不能解决这个问题。
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:0xd2af8f0 H:[UIView:0xd2a2530(302)]>",
"<NSLayoutConstraint:0xd467760 H:[UIView:0xd2a2530]-(9)-| (Names: '|':UIView:0xd2af800 )>",
"<NSLayoutConstraint:0xd2afce0 H:|-(400)-[UIView:0xd2a2530] (Names: '|':UIView:0xd2af800 )>",
"<NSAutoresizingMaskLayoutConstraint:0x179be3d0 h=--& v=--& H:[UIView:0xd2af800(320)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0xd2af8f0 H:[UIView:0xd2a2530(302)]>我正在屏幕上和屏幕下移动视图。这是我用来把它移出屏幕的代码(即错误发生的地方)。
-(void)reverseSetPickupHoverView {
self.confirmLocationViewHeightConstraint.constant = 149.0f;
self.confirmLocationViewWidthConstraint.constant = 302.0f;
self.confirmLocationViewLeftsideConstraint.constant = 400.0f;
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.5f animations:^{
[self.view layoutIfNeeded];
}];
}发布于 2014-08-08 04:38:25
让我们重新排序错误中的前三项:
"<NSLayoutConstraint:0xd2afce0 H:|-(400)-[UIView:0xd2a2530] (Names: '|':UIView:0xd2af800 )>",
"<NSLayoutConstraint:0xd2af8f0 H:[UIView:0xd2a2530(302)]>",
"<NSLayoutConstraint:0xd467760 H:[UIView:0xd2a2530]-(9)-| (Names: '|':UIView:0xd2af800 )>",因此,从superview的前缘到它的后缘有400 + 302 +9 == 711点的空间。现在:
"<NSAutoresizingMaskLayoutConstraint:0x179be3d0 h=--& v=--& H:[UIView:0xd2af800(320)]>"该superview被限制为320点宽。711 = 320。这就是冲突。
superview translatesAutoresizingMaskIntoConstraints属性被设置为true,这是最后一个约束的来源。我不确定您尝试了什么,但它没有将该属性设置为false。
什么是superview的superview?是系统控制的东西吗?在这种情况下,您将无法清除其translatesAutoresizingMaskIntoConstraints属性。相反,您必须使您的约束更加灵活,以应对系统施加的限制。
发布于 2014-08-08 04:39:50
在我看来,你在故事板中放了太多的约束。Autolayout尝试计算出X、Y、宽度和高度。在本例中,UIView的高度由两个参数设置:1)。它被限制为302和2。)通过从一些其他视图的顶部/底部分别具有(9)和(400)的垂直间距。
情况1是显而易见的。你说,它的高度必须是302。情况2就不那么明显了。例如,如果superview是1000px高,那么您的视图必须是591px高(从顶部开始是9,从底部开始是400...)
所以有一个冲突,自动布局消除了其中的一个。
我如何修复它:清除所有约束,然后手动或通过重置为建议的值来设置它们。
https://stackoverflow.com/questions/25191629
复制相似问题