UITextField-Navigation icon indicating copy to clipboard operation
UITextField-Navigation copied to clipboard

LayoutConstraints warning since iOS 13

Open Idomo opened this issue 4 years ago • 2 comments

Hi, Since I've upgraded to xCode 11 (GM) with the iOS 13 SDK, I got a warning about constraints each time the UIToolBar of the library was displayed. I didn't change anything on the constraints side so I'm guessing this is an issue with the library itself. I'd appreciate if you'll take a look on this and may find a fix.

Thanks, Ido.

 [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:0x600000dc66c0 h=--& v=--& _UIToolbarContentView:0x7fb42fef2770.height == 0   (active)>",
    "<NSLayoutConstraint:0x600000df75c0 V:|-(0)-[_UIButtonBarStackView:0x7fb42fef3240]   (active, names: '|':_UIToolbarContentView:0x7fb42fef2770 )>",
    "<NSLayoutConstraint:0x600000df7610 _UIButtonBarStackView:0x7fb42fef3240.bottom == _UIToolbarContentView:0x7fb42fef2770.bottom   (active)>",
    "<NSLayoutConstraint:0x600000dd1fe0 UIButtonLabel:0x7fb42ffbbc90'\U05e1\U05d9\U05d5\U05dd'.centerY == _UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd'.centerY + 0.5   (active)>",
    "<NSLayoutConstraint:0x600000dc5270 'TB_Baseline_Baseline' _UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd'.lastBaseline == UILayoutGuide:0x600001786680'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x600000dc52c0 'TB_Top_Top' V:|-(>=0)-[_UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd']   (active, names: '|':_UIButtonBarButton:0x7fb42fddc2d0 )>",
    "<NSLayoutConstraint:0x600000dc54a0 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x7fb42fddc2d0.height == UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x600000df73e0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide']-(0)-|   (active, names: '|':_UIButtonBarStackView:0x7fb42fef3240 )>",
    "<NSLayoutConstraint:0x600000dc51d0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600001786680'UIViewLayoutMarginsGuide']-(16)-|   (active, names: '|':_UIButtonBarButton:0x7fb42fddc2d0 )>",
    "<NSLayoutConstraint:0x600000df7340 'UIView-topMargin-guide-constraint' V:|-(0)-[UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x7fb42fef3240 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000dd1fe0 UIButtonLabel:0x7fb42ffbbc90'Done.centerY == _UIModernBarButton:0x7fb42fddc4a0'Done.centerY + 0.5   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Idomo avatar Sep 16 '19 15:09 Idomo

I don't use this library but I came across this when I was searching the same issue. Current workaround for this problem is setting a frame for a UIToolbar So change below line https://github.com/T-Pham/UITextField-Navigation/blob/73bee2ef04ed6ad4699011452a3d2f8028359e4f/UITextField-Navigation/Classes/NavigationFieldToolbar.swift#L42

to

super.init(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 35))

Apparently, iOS 13 doesn't like toolbars with zero frames.

tosbaha avatar Sep 17 '19 12:09 tosbaha

@tosbaha How did you find this "magic number" 35? It's not a good idea to use hardcoded values on this kind of things, it may change depending the OS version and device screen size.

Idomo avatar Jan 08 '20 16:01 Idomo