如何解决SwiftUi 无法同时满足约束 - 当焦点在文本字段和键盘上时打开
当我打开带有文本字段的工作表时,我将焦点放在文本字段上,然后出现键盘并显示此消息:
2021-02-06 22:29:35.817858+0100 OrientationEPS[4026:269878] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x6000030b3250 h=--& v=--& _UIButtonBarButton:0x7fea6492cf40.height == 0 (active)>","<NSLayoutConstraint:0x6000030fce60 _UIUCBKBSelectionBackground:0x7fea64930c50.bottom == _UIButtonBarButton:0x7fea6492cf40.bottom - 6 (active)>","<NSLayoutConstraint:0x6000030ec7d0 V:|-(6)-[_UIUCBKBSelectionBackground:0x7fea64930c50] (active,names: '|':_UIButtonBarButton:0x7fea6492cf40 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000030fce60 _UIUCBKBSelectionBackground:0x7fea64930c50.bottom == _UIButtonBarButton:0x7fea6492cf40.bottom - 6 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
我真的不明白绿色部分说的是什么...(NSAutoresizingMaskLayoutConstraint - NSLayoutConstraint) 你能解释一下这条消息吗? 我可以添加我的代码,但我不知道我必须发布哪个部分...
此错误消息出现在我所有以文本字段为焦点的工作表上。 (3 在我的应用中)
解决方法
我在更新到 12.4 后才开始注意到这一点(虽然我之前可能已经错过了)。经过大量调查,我发现每次 UITextField 变为活动状态时,我都会收到相同的消息。
要确认这一点,只需制作一个只有一个 UITextField 的简单应用,无论约束如何设置,都会出现相同的警告。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。