52inc / Pulley

A library to imitate the iOS 10 Maps UI.
https://cocoapods.org/pods/Pulley
MIT License
2.02k stars 265 forks source link

Modernize auto layout embedding #373

Closed radianttap closed 4 years ago

radianttap commented 4 years ago

Use NSLayoutAnchors instead of visual format.

Make sure bottom and trailing constraints are of priority 999 – this prevents AL exceptions thrown into Xcode console when you try to animate some embedded content from 0 to something. (just make sure that clip-to-bounds is ON)

With original code, if you actually try to apply insets to constraintToParent() you get this in the console:

[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:0x600001c1c1e0 h=--& v=--& UIView:0x7fdad7006790.height == 0   (active)>",
    "<NSLayoutConstraint:0x600001c65360 V:|-(20)-[UIView:0x7fdad7202f30]   (active, names: '|':UIView:0x7fdad7006790 )>",
    "<NSLayoutConstraint:0x600001c653b0 V:[UIView:0x7fdad7202f30]-(40)-|   (active, names: '|':UIView:0x7fdad7006790 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600001c653b0 V:[UIView:0x7fdad7202f30]-(40)-|   (active, names: '|':UIView:0x7fdad7006790 )>

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.
ulmentflam commented 4 years ago

Layout anchors crash on iOS 9 which Pulley supports. Updates to the project format also eliminates backwards compatibility with Xcode versions which is the advantage of using the older standard format.

ulmentflam commented 4 years ago

Quick clarification, layout anchors are known to be buggy and have a higher crash rate on iOS 9. They do not universally crash. Sorry if my first statement was unclear.