gpt4 book ai didi

出现键盘时IOS App Layout Constraint Errors

转载 作者:行者123 更新时间:2023-12-01 16:22:36 26 4
gpt4 key购买 nike

我已经构建了一个带有单个 View Controller 的简单混合应用程序,其中我放置了一个加载嵌入式 HTM5L/CSS/JS Web 应用程序的 UIWebView。

每当我的应用程序运行并且 WebView 需要用户输入时,屏幕键盘就会出现, WebView 缩小到键盘上方的剩余空间,用户输入文本,按下“完成”,屏幕键盘就会消失。对用户来说,该应用程序运行良好。

然而,在 XCode 控制台上,有大量错误被复制到下面的问题中。据我所知,这些错误在 XCode 9 之前不存在,至少我从未注意到它们,我想我会给出它们的大小。

非常感谢有关如何解决这些错误的任何帮助。您可以很正确地说,阅读错误消息,但是我已经这样做了一段时间,让我感到困惑的是我没有任何 UIButtonBars 也没有任何 UIToolBars
谢谢。

<_UIKBCompatInputView: 0x10be39850; frame = (0 0; 0 0); layer = <CALayer: 0x1c0024be0>> returned 0 width, assuming UIViewNoIntrinsicMetric
2018-07-12 16:42:30.828370+0100 MyApp[3763:346405] API error: <_UIKBCompatInputView: 0x10be39850; frame = (0 0; 0 0); layer = <CALayer: 0x1c0024be0>> returned 0 width, assuming UIViewNoIntrinsicMetric
2018-07-12 16:42:30.873906+0100 MyApp[3763:346405] [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:0x1c0284380 h=-&- v=-&- _UIToolbarContentView:0x10be1e090.width == UIToolbar:0x10be1dc50.width (active)>",
"<NSLayoutConstraint:0x1c0096b70 H:|-(8)-[_UIButtonBarStackView:0x10be1f620] (active, names: '|':_UIToolbarContentView:0x10be1e090 )>",
"<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>",
"<NSLayoutConstraint:0x1c409d560 H:|-(8)-[_UIModernBarButton:0x10bd4faa0] (active, names: '|':_UIButtonBarButton:0x10bd4f650 )>",
"<NSLayoutConstraint:0x1c409d5b0 H:[_UIModernBarButton:0x10bd4faa0]-(>=8)-| (active, names: '|':_UIButtonBarButton:0x10bd4f650 )>",
"<NSLayoutConstraint:0x1c409dba0 H:|-(>=5)-[_UIModernBarButton:0x10bd51920] (active, names: '|':_UIButtonBarButton:0x10bd512d0 )>",
"<NSLayoutConstraint:0x1c409dbf0 H:[_UIModernBarButton:0x10bd51920]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x10bd512d0 )>",
"<NSLayoutConstraint:0x1c409e690 H:|-(8)-[_UIModernBarButton:0x10bd52b30'Done'] (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c409e6e0 H:[_UIModernBarButton:0x10bd52b30'Done']-(8)-| (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c0096ad0 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10bd4f650.leading (active)>",
"<NSLayoutConstraint:0x1c0283930 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x10bd51e40.trailing (active)>",
"<NSLayoutConstraint:0x1c0283980 'UISV-spacing' H:[_UIButtonBarButton:0x10bd4f650]-(0)-[UIView:0x10bd510f0] (active)>",
"<NSLayoutConstraint:0x1c02839d0 'UISV-spacing' H:[UIView:0x10bd510f0]-(0)-[_UIButtonBarButton:0x10bd512d0] (active)>",
"<NSLayoutConstraint:0x1c0283a20 'UISV-spacing' H:[_UIButtonBarButton:0x10bd512d0]-(0)-[UIView:0x10bd51c60] (active)>",
"<NSLayoutConstraint:0x1c0283a70 'UISV-spacing' H:[UIView:0x10bd51c60]-(0)-[_UIButtonBarButton:0x10bd51e40] (active)>",
"<NSLayoutConstraint:0x1c0284470 'UIView-Encapsulated-Layout-Width' UIToolbar:0x10be1dc50.width == 0 (active)>",
"<NSLayoutConstraint:0x1c00969e0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>",
"<NSLayoutConstraint:0x1c0096a80 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1c409d5b0 H:[_UIModernBarButton:0x10bd4faa0]-(>=8)-| (active, names: '|':_UIButtonBarButton:0x10bd4f650 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-12 16:42:30.876255+0100 MyApp[3763:346405] [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:0x1c0284380 h=-&- v=-&- _UIToolbarContentView:0x10be1e090.width == UIToolbar:0x10be1dc50.width (active)>",
"<NSLayoutConstraint:0x1c0096b70 H:|-(8)-[_UIButtonBarStackView:0x10be1f620] (active, names: '|':_UIToolbarContentView:0x10be1e090 )>",
"<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>",
"<NSLayoutConstraint:0x1c409dba0 H:|-(>=5)-[_UIModernBarButton:0x10bd51920] (active, names: '|':_UIButtonBarButton:0x10bd512d0 )>",
"<NSLayoutConstraint:0x1c409dbf0 H:[_UIModernBarButton:0x10bd51920]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x10bd512d0 )>",
"<NSLayoutConstraint:0x1c409e690 H:|-(8)-[_UIModernBarButton:0x10bd52b30'Done'] (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c409e6e0 H:[_UIModernBarButton:0x10bd52b30'Done']-(8)-| (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c0096ad0 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10bd4f650.leading (active)>",
"<NSLayoutConstraint:0x1c0283930 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x10bd51e40.trailing (active)>",
"<NSLayoutConstraint:0x1c0283980 'UISV-spacing' H:[_UIButtonBarButton:0x10bd4f650]-(0)-[UIView:0x10bd510f0] (active)>",
"<NSLayoutConstraint:0x1c02839d0 'UISV-spacing' H:[UIView:0x10bd510f0]-(0)-[_UIButtonBarButton:0x10bd512d0] (active)>",
"<NSLayoutConstraint:0x1c0283a20 'UISV-spacing' H:[_UIButtonBarButton:0x10bd512d0]-(0)-[UIView:0x10bd51c60] (active)>",
"<NSLayoutConstraint:0x1c0283a70 'UISV-spacing' H:[UIView:0x10bd51c60]-(0)-[_UIButtonBarButton:0x10bd51e40] (active)>",
"<NSLayoutConstraint:0x1c0284470 'UIView-Encapsulated-Layout-Width' UIToolbar:0x10be1dc50.width == 0 (active)>",
"<NSLayoutConstraint:0x1c00969e0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>",
"<NSLayoutConstraint:0x1c0096a80 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1c409dbf0 H:[_UIModernBarButton:0x10bd51920]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x10bd512d0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-12 16:42:30.879831+0100 MyApp[3763:346405] [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:0x1c0284380 h=-&- v=-&- _UIToolbarContentView:0x10be1e090.width == UIToolbar:0x10be1dc50.width (active)>",
"<NSLayoutConstraint:0x1c0096b70 H:|-(8)-[_UIButtonBarStackView:0x10be1f620] (active, names: '|':_UIToolbarContentView:0x10be1e090 )>",
"<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>",
"<NSLayoutConstraint:0x1c409e690 H:|-(8)-[_UIModernBarButton:0x10bd52b30'Done'] (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c409e6e0 H:[_UIModernBarButton:0x10bd52b30'Done']-(8)-| (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>",
"<NSLayoutConstraint:0x1c0096ad0 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10bd4f650.leading (active)>",
"<NSLayoutConstraint:0x1c0283930 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x10bd51e40.trailing (active)>",
"<NSLayoutConstraint:0x1c0283980 'UISV-spacing' H:[_UIButtonBarButton:0x10bd4f650]-(0)-[UIView:0x10bd510f0] (active)>",
"<NSLayoutConstraint:0x1c02839d0 'UISV-spacing' H:[UIView:0x10bd510f0]-(0)-[_UIButtonBarButton:0x10bd512d0] (active)>",
"<NSLayoutConstraint:0x1c0283a20 'UISV-spacing' H:[_UIButtonBarButton:0x10bd512d0]-(0)-[UIView:0x10bd51c60] (active)>",
"<NSLayoutConstraint:0x1c0283a70 'UISV-spacing' H:[UIView:0x10bd51c60]-(0)-[_UIButtonBarButton:0x10bd51e40] (active)>",
"<NSLayoutConstraint:0x1c0284470 'UIView-Encapsulated-Layout-Width' UIToolbar:0x10be1dc50.width == 0 (active)>",
"<NSLayoutConstraint:0x1c00969e0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>",
"<NSLayoutConstraint:0x1c0096a80 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1c409e6e0 H:[_UIModernBarButton:0x10bd52b30'Done']-(8)-| (active, names: '|':_UIButtonBarButton:0x10bd51e40 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-12 16:42:30.881915+0100 MyApp[3763:346405] [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:0x1c0284380 h=-&- v=-&- _UIToolbarContentView:0x10be1e090.width == UIToolbar:0x10be1dc50.width (active)>",
"<NSLayoutConstraint:0x1c0096b70 H:|-(8)-[_UIButtonBarStackView:0x10be1f620] (active, names: '|':_UIToolbarContentView:0x10be1e090 )>",
"<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>",
"<NSLayoutConstraint:0x1c0096ad0 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10bd4f650.leading (active)>",
"<NSLayoutConstraint:0x1c0283930 'UISV-canvas-connection' UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x10bd51e40.trailing (active)>",
"<NSLayoutConstraint:0x1c0283980 'UISV-spacing' H:[_UIButtonBarButton:0x10bd4f650]-(0)-[UIView:0x10bd510f0] (active)>",
"<NSLayoutConstraint:0x1c02839d0 'UISV-spacing' H:[UIView:0x10bd510f0]-(0)-[_UIButtonBarButton:0x10bd512d0] (active)>",
"<NSLayoutConstraint:0x1c0283a20 'UISV-spacing' H:[_UIButtonBarButton:0x10bd512d0]-(0)-[UIView:0x10bd51c60] (active)>",
"<NSLayoutConstraint:0x1c0283a70 'UISV-spacing' H:[UIView:0x10bd51c60]-(0)-[_UIButtonBarButton:0x10bd51e40] (active)>",
"<NSLayoutConstraint:0x1c0284470 'UIView-Encapsulated-Layout-Width' UIToolbar:0x10be1dc50.width == 0 (active)>",
"<NSLayoutConstraint:0x1c00969e0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>",
"<NSLayoutConstraint:0x1c0096a80 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x1c01be5a0'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x10be1f620 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1c0283a70 'UISV-spacing' H:[UIView:0x10bd51c60]-(0)-[_UIButtonBarButton:0x10bd51e40] (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-12 16:42:30.882524+0100 MyApp[3763:346405] [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:0x1c0284380 h=-&- v=-&- _UIToolbarContentView:0x10be1e090.width == UIToolbar:0x10be1dc50.width (active)>",
"<NSLayoutConstraint:0x1c0096b70 H:|-(8)-[_UIButtonBarStackView:0x10be1f620] (active, names: '|':_UIToolbarContentView:0x10be1e090 )>",
"<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>",
"<NSLayoutConstraint:0x1c0284470 'UIView-Encapsulated-Layout-Width' UIToolbar:0x10be1dc50.width == 0 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1c0096bc0 _UIButtonBarStackView:0x10be1f620.trailing == _UIToolbarContentView:0x10be1e090.trailing (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

最佳答案

UIButtonBars 用于创建自定义键盘快捷键,并由 UITextInputAssistantItem 管理,当“文本字段”成为 First Responder 时调用它。为了防止冲突的约束消息,您可以初始化 ButtonGroups。当我有许多 textFields 时,我会创建一个 outlet 集合并将每个 textField 添加到集合中。然后在 ViewDidLoad 我运行以下代码:

        for textField in TextFields{
// Set BarButtonGroups to avoid layout constraint errors
textField.inputAssistantItem.leadingBarButtonGroups = []
textField.inputAssistantItem.trailingBarButtonGroups = []
}

关于出现键盘时IOS App Layout Constraint Errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51311404/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com