出现键盘时出现iOS应用布局约束错误

时间:2018-07-12 17:28:02

标签: ios layout constraints hybrid-mobile-app on-screen-keyboard

我用一个视图控制器构建了一个简单的混合应用程序,其中放置了一个UIWebView来加载嵌入式HTM5L / CSS / JS Web应用程序。

只要我的应用程序运行并且需要用户输入Web视图,屏幕上的键盘就会出现,Web视图会缩小到键盘上方的剩余空间,用户输入文字,然后按“完成”,屏幕键盘就会消失。对于用户而言,该应用可以正常运行。

但是在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.

1 个答案:

答案 0 :(得分:0)

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

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