【发布时间】:2021-05-03 04:44:52
【问题描述】:
我正在尝试创建一个 chatView 作为我的 iOS 应用程序的输入附件视图。在这个聊天视图中,有一些按钮和一个 UITextView。当这个 textView 转到下一行时,我想改变这个 chatView 的大小。但是,从框架中创建了一个名为“附件”的神秘约束。但我不知道在哪里可以找到这个约束。
这是来自 chatView 的代码 sn-p:
lazy var chatBoxView: UIView = {
let chatBoxView = UIView(frame: CGRect(x: 0, y: 0, width: 375, height: 85))
chatBoxView.translatesAutoresizingMaskIntoConstraints = false
let heightConstraint = chatBoxView.heightAnchor.constraint(equalToConstant: 120)
heightConstraint.isActive = true
...
}
所以在这里,我设置了 UIView 的框架。然后,我尝试设置一个高度约束(这只是为了测试约束是否存在冲突)。
我将 chatBoxView 设置为 inputAccessoryView。
override var inputAccessoryView: UIView? {
get {
return chatBoxView
}
}
override var canBecomeFirstResponder: Bool {
return true
}
我收到的错误消息是:
[LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x60000014d630 UIView:0x7fc7b6c840a0.height == 120 (active)>",
"<NSLayoutConstraint:0x60000014df90 'accessoryHeight' UIView:0x7fc7b6c840a0.height == 85 (active)>"
)
我不知道“<0x60000014df90 uiview:0x7fc7b6c840a0.height="=">0x60000014df90>
标签: ios swift inputaccessoryview