Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How I Learned To Stop Worrying And Love Auto Layout

How I Learned To Stop Worrying And Love Auto Layout

Light on slides and heavy on Xcode! We will dive into Interface Builder to explore areas of Auto Layout causing you to lose sleep at night.

Demo App Available at:
https://github.com/jonnyklemmer/360iDev2017

jonnyklemmer

August 16, 2017
Tweet

Other Decks in Technology

Transcript

  1. AutolayoutSampleApp[67010:16855867] [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:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)>", "<NSLayoutConstraint:0x60c00009b350 UIView:0x7ff22d102390.trailingMargin == UIView: 0x7ff22d1009c0.trailing + 44 (active)>", "<NSLayoutConstraint:0x60c00009c160 UIView:0x7ff22d1009c0.leading == UIView:0x7ff22d102390.leadingMargin + 43 (active)>", "<NSLayoutConstraint:0x60c00009c930 UILayoutGuide:0x60c0001baa20'UIViewSafeAreaLayoutGuide'.trailing == UIView:0x7ff22d102390.trailing + 16 (active)>", "<NSLayoutConstraint:0x60c00009c980 UIView:0x7ff22d102390.leading == UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'.leading + 16 (active)>", "<NSLayoutConstraint:0x6040000911c0 'UIView-Encapsulated-Layout-Width' UIView:0x7ff22d1001c0.width == 375 (active)>", "<NSLayoutConstraint:0x60c00009c840 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'](LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>", "<NSLayoutConstraint:0x60c00009c8e0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide']-(0)-|(LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
  2. AutolayoutSampleApp[67010:16855867] [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:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)>", "<NSLayoutConstraint:0x60c00009b350 UIView:0x7ff22d102390.trailingMargin == UIView: 0x7ff22d1009c0.trailing + 44 (active)>", "<NSLayoutConstraint:0x60c00009c160 UIView:0x7ff22d1009c0.leading == UIView:0x7ff22d102390.leadingMargin + 43 (active)>", "<NSLayoutConstraint:0x60c00009c930 UILayoutGuide:0x60c0001baa20'UIViewSafeAreaLayoutGuide'.trailing == UIView:0x7ff22d102390.trailing + 16 (active)>", "<NSLayoutConstraint:0x60c00009c980 UIView:0x7ff22d102390.leading == UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'.leading + 16 (active)>", "<NSLayoutConstraint:0x6040000911c0 'UIView-Encapsulated-Layout-Width' UIView:0x7ff22d1001c0.width == 375 (active)>", "<NSLayoutConstraint:0x60c00009c840 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'](LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>", "<NSLayoutConstraint:0x60c00009c8e0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide']-(0)-|(LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
  3. AutolayoutSampleApp[67010:16855867] [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:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)>", "<NSLayoutConstraint:0x60c00009b350 UIView:0x7ff22d102390.trailingMargin == UIView: 0x7ff22d1009c0.trailing + 44 (active)>", "<NSLayoutConstraint:0x60c00009c160 UIView:0x7ff22d1009c0.leading == UIView:0x7ff22d102390.leadingMargin + 43 (active)>", "<NSLayoutConstraint:0x60c00009c930 UILayoutGuide:0x60c0001baa20'UIViewSafeAreaLayoutGuide'.trailing == UIView:0x7ff22d102390.trailing + 16 (active)>", "<NSLayoutConstraint:0x60c00009c980 UIView:0x7ff22d102390.leading == UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'.leading + 16 (active)>", "<NSLayoutConstraint:0x6040000911c0 'UIView-Encapsulated-Layout-Width' UIView:0x7ff22d1001c0.width == 375 (active)>", "<NSLayoutConstraint:0x60c00009c840 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'](LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>", "<NSLayoutConstraint:0x60c00009c8e0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide']-(0)-|(LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
  4. AutolayoutSampleApp[67010:16855867] [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:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)>", "<NSLayoutConstraint:0x60c00009b350 UIView:0x7ff22d102390.trailingMargin == UIView: 0x7ff22d1009c0.trailing + 44 (active)>", "<NSLayoutConstraint:0x60c00009c160 UIView:0x7ff22d1009c0.leading == UIView:0x7ff22d102390.leadingMargin + 43 (active)>", "<NSLayoutConstraint:0x60c00009c930 UILayoutGuide:0x60c0001baa20'UIViewSafeAreaLayoutGuide'.trailing == UIView:0x7ff22d102390.trailing + 16 (active)>", "<NSLayoutConstraint:0x60c00009c980 UIView:0x7ff22d102390.leading == UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'.leading + 16 (active)>", "<NSLayoutConstraint:0x6040000911c0 'UIView-Encapsulated-Layout-Width' UIView:0x7ff22d1001c0.width == 375 (active)>", "<NSLayoutConstraint:0x60c00009c840 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide'](LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>", "<NSLayoutConstraint:0x60c00009c8e0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide: 0x60c0001baa20'UIViewSafeAreaLayoutGuide']-(0)-|(LTR) (active, names: '|':UIView:0x7ff22d1001c0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60c00009c070 UIView:0x7ff22d1009c0.width == 300 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
  5. 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.
  6. 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.
  7. Do this instead: 2) Reason about the layout 3) Find

    the constraint(s) 4) Final resort: dig around in that messy stack trace 5) FINAL final resort: Reset & Redo 1) Track down the offenders &