ios 交换UITextFields约束问题

ufj5ltwl  于 2023-05-23  发布在  iOS
关注(0)|答案(3)|浏览(170)

我有一个EditProfileViewController,带有一个tableview和textfield。在其中一个文本字段中,我有一个pickerView作为inputView,在inputAccessoryView中有一个toolBar。当视图加载时,我选择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的一个bug,因为在iOS 10的另一个设备上,这种情况并没有发生。
消除此约束问题的解决方法是设置autoCorrectionType = false。但我想启用它。我想这是因为我在countryTextfield的inputView中有一个pickerView,但我不知道如何解决这个问题。

bf1o4zei

bf1o4zei1#

这开始发生在我的应用程序与iOS13,我怀疑这是一个错误。在尝试了所有我能想到的方法后,我关闭了自动更正,不再遇到约束问题。

textEdit.autocorrectionType = .no
holgip5t

holgip5t2#

试试这个

  • 如果您已经从情节提要中添加了pickerView,请将其删除。
  • make pickerView. translates自动调整大小MaskIntoConstraints = false

因为我们不希望在inputView上有任何约束,但是AutoresizingMask获得了默认的空间约束,这会发生冲突。
我是第一次在这里回答,所以如果出了问题,我道歉。

5hcedyr0

5hcedyr03#

潜在的快速修复:
我可能有一个快速解决约束错误的方法-确保将键盘设置为
更正:无智能插页:没有

相关问题