How to fix Auto Layout issues in iOS

Issue #369

UITemporaryLayoutHeight and UITemporaryLayoutWidth

  • Demystify warnings with https://www.wtfautolayout.com/
  • Reduce priority
  • Use Auto Layout directly instead of using manual frame layout, specially for scrolling pager

NSAutoresizingMaskLayoutConstraint

  • Check that a view ACTUALLY has translatesAutoresizingMaskIntoConstraints set to false

UISV-spacing, UISV-distributing

  • Check UIStackView
  • Set stackview.alignment = .center if you see UIStackView trying to set same trailing or leading edges for its subviews
  • Reduce priority if there’s edge constraints break from subviews to UIStackView

Intrinsic size between UIImageView and UILabel

  • When constraint to each other, can cause UILabel to disappear
  • Reduce compression resistance
1
imageView.setContentCompressionResistancePriority(UILayoutPriority.defaultLow, for: .vertical)

UIAlertController sheet width == - 16

https://stackoverflow.com/a/58666480/1418457

Read more

Comments