Giter Site home page Giter Site logo

auto-layout-deep-dive-swift's Introduction

auto-layout-deep-dive-swift

Reference: https://medium.com/@bhupendra.trivedi14/understanding-custom-uiview-in-depth-setting-file-owner-vs-custom-class-e2cab4bb9df8

File Owner vs Custom Class (via Indentiy Inspector)

This is a great medium article explaining the different setups for .xibs. There are two methods for loading an .xib:

  1. instantiate(withOwner:options:)
  2. Bundle.main.loadNibNamed(_:owner:options:)
  • If you are using Custom Class, you should use Bundle.main.loadNibNamed(_:owner:options:). You cannot load the UINib in the init(coder:) method of the custom class otherwise you will end up with a retain cycle. It must be done in an external class such as a ResuableXibView or a UIViewController. You are not able to create an @IBOutlet in another storyboard view using this approach. You are resticted to progammatic (I think).

  • If you are using File Owner, you should use instantiate(withOwner:options:) in the File Owner's class. This is the more flexible and reusable option where you have the freedom to instantiate the view both programatically and via storyboard.

Size Classes

  • It is straight forward. The painful part of size classes is that iPhone Max and Pro models have a regular width where as the base models have a compact width.

Scroll View Layout Guides

  • Content Layout Guide: Position Constraints.
  • Frame Layout Guide: Size Constraints (250 priority on the scroll direction).

Debugging

  • When using the Debug View Hieracy, it's very helpful to the print the description of the ui element to the console (via right click). You are then able to use the memory address to filter out the noise in the view hierachy.
  • Accessbility Inspect has an audit tool and it is amazing!

auto-layout-deep-dive-swift's People

Contributors

james-jasenia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.