1 / 8

AUTO LAYOUT BASICS

Mikhail Merkulov @ mikhailmerkulov. AUTO LAYOUT BASICS. The problem. The problem with springs and struts Traditional solutions Hard-coded layout 2+ nibs Auto layout What about iPhone 5?. Auto layout concept. Constraint-based layout Frames are determined automatically

nitara
Download Presentation

AUTO LAYOUT BASICS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mikhail Merkulov @mikhailmerkulov AUTO LAYOUT BASICS

  2. The problem • The problem with springs and struts • Traditional solutions • Hard-coded layout • 2+ nibs • Auto layout • What about iPhone 5?

  3. Auto layout concept • Constraint-based layout • Frames are determined automatically • attribute1 == multipler × attribute2 + constant • Button.left = superview.left + 10 • New class: NSLayoutConstraint • Immutable except Constant property • Demo

  4. How to code auto layout? • Low level API • The visual format language • Demo

  5. Runtime problems • The constraints must be sufficient • Ambiguous layout • The constrains must not conflict • Unsatisfiable constraints • Unexpected ways • Demo

  6. Migrating to auto layout • Partial and full conversion? • Convert nibs • Review programmatically created views • Replace setFrame, etc. • Rethink your layout (Divide responsibility between controllers and views) • Add constraints • updateConstraints and intrinsicContentSize

  7. References • Cocoa Auto Layout Guide • Session 202: Introduction to Auto Layout for iOS and OS X • Session 228: Best Practices for Mastering Auto Layout • Session 232: Auto Layout by Example • Beginning Auto Layout in iOS 6

  8. Questions?

More Related