【问题标题】:Swapping through UITextFields constraint issue通过 UITextFields 约束问题交换
【发布时间】:2020-04-14 08:15:10
【问题描述】:

我有一个带有表格视图和文本字段的 EditProfileViewController。在其中一个文本字段中,我有一个作为 inputView 的 pickerView 和一个在 inputAccessoryView 中的工具栏。当视图加载并且我选择 firstName 文本字段,然后返回并移动到 lastName 文本字段时,我会收到一个约束警告。

[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:0x2809a4640 'assistantHeight' TUISystemInputAssistantView:0x1113b11a0.height == 45   (active)>",
"<NSLayoutConstraint:0x2809a0320 'assistantView.bottom' TUISystemInputAssistantView:0x1113b11a0.bottom == _UIKBCompatInputView:0x11a437e80.top   (active)>",
"<NSLayoutConstraint:0x2809a05a0 'assistantView.top' V:|-(0)-[TUISystemInputAssistantView:0x1113b11a0]   (active, names: '|':UIInputSetHostView:0x11d06ce50 )>",
"<NSLayoutConstraint:0x280943840 'inputView.top' V:|-(0)-[_UIKBCompatInputView:0x11a437e80]   (active, names: '|':UIInputSetHostView:0x11d06ce50 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2809a0320 'assistantView.bottom' TUISystemInputAssistantView:0x1113b11a0.bottom == _UIKBCompatInputView:0x11a437e80.top   (active)>

当我在两个默认文本字段之间切换时,会发生这种情况,我不明白为什么。 我做了一些研究,据我所知,这是 iOS 13 的一个错误,因为在另一台装有 iOS 10 的设备上,这并没有发生。

消除此约束问题的解决方法是设置 autoCorrectionType = false。但我想启用它。我认为发生这种情况是因为我在countryTextfield的inputView中有一个pickerView,但我不知道如何解决这个问题。

【问题讨论】:

    标签: ios uitextfield swift4 uipickerview


    【解决方案1】:

    这开始在我的 iOS13 应用中发生,我怀疑这是一个错误。在尝试了我能想到的一切之后,我关闭了自动更正并停止遇到约束问题。

    textEdit.autocorrectionType = .no
    

    【讨论】:

    • 太棒了!拯救了我的一天
    【解决方案2】:

    潜在的快速修复:

    我可能有一个快速解决约束错误的方法 - 请确保您将键盘设置为

    更正:否 智能插入:否

    【讨论】:

      猜你喜欢
      • 2011-07-06
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      相关资源
      最近更新 更多