本文介绍了SwiftUi 无法同时满足约束 - 当焦点在文本字段和键盘上时打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开带有文本字段的工作表时,我将焦点放在文本字段上,然后出现键盘并显示此消息:

When I open a sheet with textfield, and I focus on textfield, then keyboard appears and this message appears :

 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)你能解释一下这条消息吗?我可以添加我的代码,但我不知道我必须发布哪个部分...

I don't really understand what the green part says... (NSAutoresizingMaskLayoutConstraint - NSLayoutConstraint)Can you explain me this message ?I can add my code, but I don't know which part I have to post...

此错误消息出现在我所有以文本字段为焦点的工作表上.(3 在我的应用中)

This error message appear on all my sheets with textfield focused. (3 in my app)

我的应用的屏幕截图.

推荐答案

我在更新到 12.4 后才开始注意到这一点(虽然我之前可能已经错过了).经过大量调查,我发现每次 UITextField 变为活动状态时,我都会收到相同的消息.

I just started noticing this after updating to 12.4 (although I might have missed it before). After much investigation, I found that I get the same messages every time a UITextField becomes active.

要确认这一点,只需制作一个只有一个 UITextField 的简单应用,无论约束如何设置,都会出现相同的警告.

To confirm this, just make a simple app with only a single UITextField, and irregardless of how the constraints are set or not, the same warnings will appear.

这篇关于SwiftUi 无法同时满足约束 - 当焦点在文本字段和键盘上时打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:40