This session sums up most of the mysteries of auto layout developers come across.
Constraints change -> Deferred Layout Pass -> Application Run Loop
Engine recomputes the layout
setNeedsUpdateConstraints()layoutSubViews()setNeedsUpdateConstraints() as it already done beforeset translatesAutoresizingMaskIntoConstraints to false for programmatically created views in order to flag the engine to not create constraints for autoresizing masks
IB takes care it.
iOS 9 new anchor property to make the code more readable
view.topAnchor.constraintEqualToAnchor(view.topAnchor, costant:10)
view.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor, costant:10)
We often create dummy views for layouting or grouping some UI elements.
UILayoutGuide is new class in iOS 9 for representing a rectangle in layout engine
var layoutMarginsGuide: UILayoutGuide for internal padding of a view
(lldb) [view constraintsAffectingLayoutForAxis:1] for debugging only one axis ( 0 = horizontal , 1 = vertical)(lldb) [view _autolayoutTrace] for showing all constraints in debug logsview.hasAmbiguousLayout() to see if the view has Ambiguous Layouts(lldb) [view exerciseAmbiguityInLayout] for simulator running Ambiguous Layouts and (lldb) c to resume the processRelated Session