- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我遇到了一些无法解决的约束问题。如果我能更好地理解控制台窗口中的错误消息(特别是与 NSLayoutConstraints
相关的),我想我会发现它真的很有帮助。这是一个例子:
我有这个约束:
NSLayoutConstraint(item: mainView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 0)
这对我来说很有意义,我想让 mainView
的高度与 self.view
完全相同。然而,这会产生错误:
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:0x7a94fa10 UIView:0x7a9f95c0.height == UIView:0x7a9d1660.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7a9488a0 h=--& v=--& V:[UIView:0x7a9f95c0(110)]>",
"<NSLayoutConstraint:0x7a948490 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7a9d1660(430)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7a94fa10 UIView:0x7a9f95c0.height == UIView:0x7a9d1660.height>
我已经注释掉了除此之外的所有其他约束,但我仍然遇到此错误。我认为约束与自身冲突是否正确?
谁能指出正确的方向来解决这个问题?
最重要的是,如果有人能帮助我理解这些 NSLayoutConstraint
错误消息,那将非常有帮助。
--
请注意,我在这里使用的是 Swift,但我不介意答案是否在 Objective C 中。
最佳答案
mainView.translatesAutoresizingMaskIntoConstraints = NO。//对象mainView.translatesAutoresizingMaskIntoConstraints = false。// swift
它会起作用的!
谢谢
关于ios - NSLayoutConstraint "Unable to simultaneously satisfy constraints"错误以及如何解释它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28672326/
我写了一个我认为是 quite interesting question 的答案,但不幸的是,在我发布之前,该问题已被作者删除。我在这里重新发布问题的摘要和我的答案,以防其他人有用。 假设我有一个 S
有没有办法写约束: C t1 t2 :: Constraint 如果 t2 与 t1 匹配,它“满足”(这是正确的词)。 例如: C (forall a. Num a => a -> a -> a)
我正在尝试用这段代码求解方程: a = [-0.0008333 -0.025 -0.6667 -20]; length_OnePart = 7.3248; xi = -6.4446; yi = -16
我知道我可以关闭 MySQL 中的安全模式,所以我不会尝试解决这个问题。 我有一个简单的表格: create table rubbish( id int auto_increment prim
尝试刷新我的 sencha extjs 应用程序并总是收到此错误: 命令: sencha 应用程序刷新 sencha 应用升级 总是同样的错误: [ERR] Cannot satisfy requir
我正在尝试为我的项目创建一个测试套件,HaskSplit在我的 .cabal 配置中: -- Initial HaskSplit.cabal generated by cabal init. For
我有 pc/sc 读卡器和非接触式卡(mifare 卡),我可以连接到该卡,并且我也成功执行 getdate 命令,但是当我想进行身份验证时,我看到此错误“6982:安全状态不满足”我已经尝试了这 3
简而言之,流程如下: inputChannel->transformer->firstOutboundAdapter->pollingOutboundAdapter 概要:inputChannel 接
这个问题在这里已经有了答案: Why do try!() and ? not compile when used in a function that doesn't return Option o
我正在尝试切片矢量并在 Rust 中同时打印它。这是我的代码: fn main() { let a = vec![1, 2, 3, 4]; println!("{:?}", a[1..
我正在尝试自定义约束 菜单栏类: import UIKit class ManuBar: UIView { override init(frame: CGRect) { sup
我遇到了这个问题,我有一个聊天服务器需要与托管在 aws 中的 lambda 服务进行通信,但云前端会引发以下错误。 BODY: ERROR: The request could not be s
我有一个包含Arc>的结构,我试图添加一个获取self所有权的方法,并将所有权移到新线程中并启动它。但是,我得到了错误 error[E0277]: the trait bound `std::sync
我遇到了一个编译错误,似乎突出显示了我对类型系统不了解的内容。 我想将字符串转换为整数,如果字符串不是有效整数,则带有自定义 panic 消息。我做一个match在 Result由 parse() 返
这是应用过滤器后复制数据的代码。 Sub read_excel_file(path_to_current_work_book As String, path_to_destination_work
我们有一个 shell 脚本,可以自动准备虚拟环境,然后在其中运行测试。部分脚本安装要求: pip install -r requirements.txt 当脚本多次运行时,它会针对每个要求打印一条警
总是遇到 FoodTracker 教程;遵循此步骤:“实现自定义控件” https://developer.apple.com/library/content/referencelibrary/Get
我收到此错误: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in th
我有一个 UITableViewCell我正在创建,并且我正在使用带有完全在代码中构建的约束的自动布局。 虽然应用程序中的实际输出很好(即,它看起来就像我设计的那样),但我收到了著名的“无法同时满足约
这个问题在这里已经有了答案: Disable autolayout constraint error messages in debug console output in Xcode (5 个回答)
我是一名优秀的程序员,十分优秀!