iphone - 无法同时满足约束

标签 iphone ios objective-c

实际上使用 xib 集成相机应用程序,因为我将 uiview 放在 View 上,然后我放 imageview,再次在 imageview 上查看以进行裁剪。然后运行我得到这个错误的项目。

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.

最佳答案

错误就是它所说的,并为您开始调试提供了非常明确的说明。有两个冲突的约束。每个都指示自动布局运行时做一些相互矛盾的事情。

如果您以编程方式创建和添加 View ,那么 Auto Resizing 属性很可能已自动转换为 Auto Layout 约束。

因此,首先要尝试的是,使用您以编程方式创建的 View ,通过设置禁用它:

myProgrammaticView.translatesAutoresizingMaskIntoConstraints = NO;

关于iphone - 无法同时满足约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17803801/

相关文章:

iphone - Xcode 单元测试

iOS放大 View 不显示

objective-c - 记录项目中所有 UIViewController 的类名

ios - 如何根据图形宽度截断 NSString?

iphone - 以与 Facebook oauth key 类似的方式获取 Twitter oauth key

iphone - 自定义按钮的核心图形与图像

objective-c - @属性赋值

iphone - 没有nib文件的通用申请会被拒吗?

ios - Sprite 不跟踪计数

iphone - 如何确定正在编辑 UITableView 中的哪个节标题