1
votes

When a UITextField has focus and I select a different UITextField, I receive the following errors (only with the `iPad):

[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:0x60400028fa50 h=--& v=--& UIKeyboardAssistantBar:0x7f8895c0e5f0.height == 0 (active)>", "<NSLayoutConstraint:0x60c000289d30 V:|-(0)-[_UIButtonBarStackView:0x7f8895c11180] (active, names: '|':UIKeyboardAssistantBar:0x7f8895c0e5f0 )>", "<NSLayoutConstraint:0x60c00028b130 V:[_UIButtonBarStackView:0x7f8895c11180]-(0)-| (active, names: '|':UIKeyboardAssistantBar:0x7f8895c0e5f0 )>", "<NSLayoutConstraint:0x60400028ec90 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x7f8895e2f950.height == UILayoutGuide:0x60c0001a7700'UIViewLayoutMarginsGuide'.height (active)>", "<NSLayoutConstraint:0x60c000285f50 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x60c0001a7700'UIViewLayoutMarginsGuide']-(9)-| (active, names: '|':_UIButtonBarStackView:0x7f8895c11180 )>", "" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c000285f50 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x60c0001a7700'UIViewLayoutMarginsGuide']-(9)-| (active, names: '|':_UIButtonBarStackView:0x7f8895c11180 )>

NB

I am using a UICollectionViewController and all my UITextFields are inside UICollectionViewCells.

The problem I have appears to be the same as this. Also, I the keyboard type as decimal.

2
can you upload photo of constraints of labels in UICollectionViewCells. - Abhishek Jadhav
It seems to be a bug. Here´s a related radar: openradar.appspot.com/36578167 - Philipp Otto

2 Answers

0
votes

If I press command + k before switching TextFields, then I don't get any constraint errors.

0
votes

The debug log is full in the link:

    (  
        "<NSAutoresizingMaskLayoutConstraint:0x7f86bb4bbd80 h=--& v=--& V:[UIKeyboardAssistantBar:0x7f86bb53b9a0(0)]>",  
        "<NSLayoutConstraint:0x7f86bb544270 V:|-(0)-[_UIButtonBarStackView:0x7f86bb53c5d0]   (Names: '|':UIKeyboardAssistantBar:0x7f86bb53b9a0 )>",  
        "<NSLayoutConstraint:0x7f86bb5442c0 V:[_UIButtonBarStackView:0x7f86bb53c5d0]-(0)-|   (Names: '|':UIKeyboardAssistantBar:0x7f86bb53b9a0 )>",  
        "<NSLayoutConstraint:0x7f86bb760b40 V:|-(0)-[_UIUCBKBSelectionBackground:0x7f86bb760690]   (Names: '|':_UIButtonBarButton:0x7f86bb75f1a0 )>",  
        "<NSLayoutConstraint:0x7f86bb760c10 _UIUCBKBSelectionBackground:0x7f86bb760690.bottom == _UIButtonBarButton:0x7f86bb75f1a0.bottom>",  
        "<NSLayoutConstraint:0x7f86bb760f00 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x7f86bb75f1a0.height == UILayoutGuide:0x7f86bb53f9b0'UIViewLayoutMarginsGuide'.height>",  
        "<NSLayoutConstraint:0x7f86bb53fb20 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x7f86bb53f9b0'UIViewLayoutMarginsGuide']-(3)-|   (Names: '|':_UIButtonBarStackView:0x7f86bb53c5d0 )>",  
        "<NSLayoutConstraint:0x7f86bb53fa80 'UIView-topMargin-guide-constraint' V:|-(10)-[UILayoutGuide:0x7f86bb53f9b0'UIViewLayoutMarginsGuide']   (Names: '|':_UIButtonBarStackView:0x7f86bb53c5d0 )>"  
    )  

I can get the conflict from this log:

  • 1: UIKeyboardAssistantBar's height is 0
  • 2+3: _UIButtonBarStackView's top and bottom is equal to UIKeyboardAssistantBar's, so _UIButtonBarStackView's height is 0 too.
  • 7+8: UILayoutGuide's top has 10 to _UIButtonBarStackView and it's bottom has 3 to _UIButtonBarStackView.
  • 6: _UIButtonBarButton's height is equal to UILayoutGuide's height
  • 4+5: _UIUCBKBSelectionBackground's height is equal to _UIButtonBarButton's height.

The min height of _UIUCBKBSelectionBackground is 0, so the min height of UIKeyboardAssistantBar is 13, but now it has constraint :height = 0。As this constraint is NSAutoresizingMaskLayoutConstraint, it's generated by system, so I think the solution is set UIKeyboardAssistantBar.translatesAutoresizingMaskIntoConstraints to NO (default is YES).