4

I'm creating an iPad-App with an UIView that has two UITextFields in it.
Whenever I run my App and I click in one of the UITextFields and then on the other one (order doesn't matter) it always throws an error, that it has to break a constraint.
I even put two completely new UITextFields on the UIView without any constraints at all and it still shows me that error.

[LayoutConstraints] Unable to simultaneously satisfy constraints.
(
    "<NSLayoutConstraint:0x600003db4c80 'assistantHeight' TUISystemInputAssistantView:0x7fdc1f423400.height == 55   (active)>",
    "<NSLayoutConstraint:0x600003dae940 'assistantView.bottom' TUISystemInputAssistantView:0x7fdc1f423400.bottom == _UIKBCompatInputView:0x7fdc1f21bb20.top   (active)>",
    "<NSLayoutConstraint:0x600003dae8f0 'assistantView.top' V:|-(0)-[TUISystemInputAssistantView:0x7fdc1f423400]   (active, names: '|':UIInputSetHostView:0x7fdc1f432480 )>",
    "<NSLayoutConstraint:0x600003da4d70 'inputView.top' V:|-(0)-[_UIKBCompatInputView:0x7fdc1f21bb20]   (active, names: '|':UIInputSetHostView:0x7fdc1f432480 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600003dae940 'assistantView.bottom' TUISystemInputAssistantView:0x7fdc1f423400.bottom == _UIKBCompatInputView:0x7fdc1f21bb20.top   (active)>


I even tried the symbolic-breakpoint-thing where you get a more detailed report, but I can't find any clues what is wrong here:

UIWindow:0x7fa39f3092a0
|   UITransitionView:0x7fa39f20f360
|   |   UIDropShadowView:0x7fa39f20fa40
|   |   |   UIView:0x7fa39f20f880
|   |   |   |   •UIView:0x7fa39f20b690
|   |   |   |   |   *<UILayoutGuide: 0x6000010e47e0 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 24}, {834, 1088}}, owningView = <UIView: 0x7fa39f20b690; frame = (0 0; 834 1112); autoresize = W+H; layer = <CALayer: 0x600002914fa0>>>
|   |   |   |   |   *UILabel:0x7fa39f20c590'Patient:'
|   |   |   |   |   *UITextField:0x7fa3a1025c00
|   |   |   |   |   |   _UITextFieldRoundedRectBackgroundViewNeue:0x7fa39f20ba90
|   |   |   |   |   |   *_UIBaselineLayoutStrut:0x7fa3a190a320
|   |   |   |   |   |   _UITextFieldCanvasView:0x7fa39f20b340
|   |   |   |   |   *UITextField:0x7fa39f83be00
|   |   |   |   |   |   _UITextFieldRoundedRectBackgroundViewNeue:0x7fa39f20b140
|   |   |   |   |   |   *_UIBaselineLayoutStrut:0x7fa3a1909cb0
|   |   |   |   |   |   UIFieldEditor:0x7fa3a2815000
|   |   |   |   |   |   |   _UITextFieldCanvasView:0x7fa39f20c1f0
|   |   |   |   |   |   |   |   UITextSelectionView:0x7fa39e40a100
|   |   |   |   |   *UIButton:0x7fa39f708b60'Start'
|   |   |   |   |   |   UIButtonLabel:0x7fa3a19063d0'Start'
|   |   |   |   |   *UILabel:0x7fa39f20d200'Sitzung:'
|   |   |   |   |   *UILabel:0x7fa39f709de0'Felder dürfen nicht leer ...'
|   |   |   |   |   *UIButton:0x7fa39f20d480'Daten'
|   |   |   |   |   |   UIButtonLabel:0x7fa3a1909300'Daten'


Is there anything that I'm missing, or a way to fix that error?
I have the same problem with other TextFields in my project and I tried everything from putting the TextFields into a new View or adding/removing constraints.

Diafreak
  • 41
  • 1
  • 3

2 Answers2

1

The problem is that you have assign also an height constraint, so you can remove o the height constraint or the bottom constraint. Otherwise there is another solution, you can set the height constraint not as "equal" but as "greater than", to be sure that the textfield will never be overlap the view below

Andrea
  • 249
  • 1
  • 5
  • I usually set an aspect ratio and the width equal to the view for the auto layout, shouldn't the height be set by the aspect ratio? – Diafreak May 08 '20 at 22:08
  • Yes it can be set by aspect ratio, but in this case when the height constraint and the bottom constraint can't be satisfied at the same time, you can decrease the priority of one of the constraint or change the bottom constraint into greater than – Andrea May 09 '20 at 09:00
  • I tried both, changing height and width priority and putting them on "greater than or equal", nothing has changed. The weird thing is that it only happens when I click into the TextField, when I use Tab to get to the next one no error shows up... – Diafreak May 12 '20 at 16:10
1

The layout constraint error message has nothing to do with your layout.

It's an internal issue (could be considered a bug) with the Input Assistant View - the auto-complete options shown above the keyboard.

DonMag
  • 69,424
  • 5
  • 50
  • 86
  • oh, okay, thank you, good to know. Is there a way to fix that, will for example disabling the auto-complete remove the error? – Diafreak May 12 '20 at 16:12
  • 3
    Yes - either set `Correction: No` in Storyboard or `textView.autocorrectionType = .no` via code. – DonMag May 12 '20 at 17:09
  • Wish that would solve it, but I turned the correction off since the beginning, and I also tried it in code and sadly nothing changed. But thanks for the advice anyway. – Diafreak May 12 '20 at 19:06
  • Very nice. This solved my problem after settings "Correction" and "Spell Checking" to NO. – Kibernetik Oct 23 '21 at 16:14