实际上使用xib集成了相机应用程序,我将uiview放在视图上,之后我将imageview,再次在imageview上查看以进行裁剪。然后运行项目我收到此错误。
2013-07-23 12:45:49.936 Camera_App1 [30668:907]无法同时满足约束条件。可能至少下列列表中的一个约束是您不想要的约束。试试这个:(1)看看每个约束并试着找出你不期望的东西; (2)找到添加了不需要的约束或约束的代码并修复它。 (注意:如果你看到你不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性的文档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.
答案 0 :(得分:22)
错误就是它所说的,并为您提供了非常明确的指令供您开始调试。有两个冲突的约束。每个都指示自动布局运行时执行与另一个相矛盾的操作。
如果以编程方式创建和添加视图,则自动调整大小属性可能会自动转换为自动布局约束。
因此,首先要尝试的是,使用以编程方式创建的视图,通过设置禁用此功能:
myProgrammaticView.translatesAutoresizingMaskIntoConstraints = NO;
答案 1 :(得分:1)
我知道这个帖子很老,但这是我的经验和解决方案。
选择视图(UILabel,UIImage等)编辑器&gt; Pin&gt; (选择...)到Superview Editor&gt;解决自动布局问题&gt;添加缺失约束
此错误是您添加的约束之间的冲突。删除不需要的约束。不要在同一方向和类型中使用多个约束。
我建议您使用SnapKit。它是一个Autolayout框架,使用起来非常方便
import SnapKit
var label = UILabel()
label.snp_makeConstraints { (make) -> Void in
make.centerX.equalTo(0)
make.centerY.equalTo(0)
make.width.equalTo(30)
make.height.equalTo(30)
}
答案 2 :(得分:1)
答案 3 :(得分:0)
就我而言,由于导航栏,我遇到此错误。添加新的UIViewController导致此错误。
我删除了旧的导航栏,然后通过转到 编辑器➞嵌入➞导航控制器。
答案 4 :(得分:-1)
我重置为建议的约束,它解决了问题see here.
选择对象>编辑器>解决自动布局问题>重置为建议的约束