无法同时满足约束

编程入门 行业动态 更新时间:2024-10-21 09:49:12
本文介绍了无法同时满足约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

实际上使用xib集成了相机应用程序,我将uiview放在视图上,之后我将imageview,再次在imageview上查看以进行裁剪。然后运行项目我收到此错误。

Actually integrated camera application using xib, in that I placed uiview on a view, after that I put imageview, again view on imageview for cropping. then run the project I got this error.

2013-07-23 12:45:49.936 Camera_App1 [30668:907]无法同时满足约束条件。可能至少下列列表中的一个约束是您不想要的约束。试试这个:(1)看看每个约束并试着找出你不期望的东西; (2)找到添加了不需要的约束或约束的代码并修复它。 (注意:如果你看到你不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性translatesAutoresizingMaskIntoConstraints的文档)

2013-07-23 12:45:49.936 Camera_App1[30668:907] 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:0x1f5b3d10 h=--& v=--& V:[UIView:0x1f5a2f70(460)]>", "<NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-| (Names: '|':UIView:0x1f5a3120 )>", "<NSLayoutConstraint:0x1f5a3f80 V:|-(0)-[UIView:0x1f5a3120] (Names: '|':UIView:0x1f5a2f70 )>", "<NSLayoutConstraint:0x1f5a3f40 V:[UIView:0x1f5a3120]-(63)-| (Names: '|':UIView:0x1f5a2f70 )>", "<NSLayoutConstraint:0x1f5a3bc0 V:|-(61)-[UIView:0x1f5a31b0] (Names: '|':UIView:0x1f5a3120 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-| (Names: '|':UIView:0x1f5a3120 )> 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. 2013-07-23 12:45:58.697 Camera_App1[30668:907] media type=public.image 2013-07-23 12:45:58.701 Camera_App1[30668:907] global=public.image 2013-07-23 12:45:58.858 Camera_App1[30668:907] 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:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-| (Names: '|':UIView:0x1f5a3120 )>", "<NSLayoutConstraint:0x1f5a3f80 V:|-(0)-[UIView:0x1f5a3120] (Names: '|':UIView:0x1f5a2f70 )>", "<NSLayoutConstraint:0x1f5a3f40 V:[UIView:0x1f5a3120]-(63)-| (Names: '|':UIView:0x1f5a2f70 )>", "<NSLayoutConstraint:0x1f5a3bc0 V:|-(61)-[UIView:0x1f5a31b0] (Names: '|':UIView:0x1f5a3120 )>", "<NSAutoresizingMaskLayoutConstraint:0x1f53a430 h=--& v=--& V:[UIView:0x1f5a2f70(460)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-| (Names: '|':UIView:0x1f5a3120 )> 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.

推荐答案

错误就是它所说的,并且非常明确您开始调试的说明。有两个冲突的约束。每个都指示自动布局运行时执行与另一个相矛盾的操作。

The error is what it says, and gives quite clear instructions for you to begin debugging. There are two constraints that conflict. Each instructs the Auto Layout runtime to do something that contradicts the other.

如果您是以编程方式创建和添加视图,则自动调整大小属性可能会自动转换为自动布局约束。

If you are creating and adding views programmatically, then chances are Auto Resizing attributes have been automatically translated to Auto Layout constraints.

因此,首先要尝试的是,使用以编程方式创建的视图,通过设置禁用此功能:

So, the first thing to try is, with your programmatically created views, disable this by setting:

myProgrammaticView.translatesAutoresizingMaskIntoConstraints = NO;

更多推荐

无法同时满足约束

本文发布于:2023-11-27 09:18:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637476.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!