Quick thoughts on Auto Layout
Auto Layout is a new feature in iOS 6.0 that’s meant to help developers create user interfaces that adapt to different screen sizes and orientations. In practice, it can be tricky to use. Others might even argue that it’s not really ready for regular development.
In any case, I spent a few hours with working with Auto Layout constraints in order to make a few views that had been designed for the 4″ iPhone screen size (iPhone 5) capable of adapting to a 3.5″ screen size (previous iPhone models.)
Here are several very quick observations on working with Auto Layout:
- Moving controls in Interface Builder will change constraints in the view and you may in effect, lose constraints that you have set up.
- Sometimes you may need to experiment and create new constraints in order to change automatic constraints (xCode generated and not editable) into user constraints (editable and deletable).
- Turning auto layout off and on again in the File Inspector will clear out all constraints. This includes the ones you may have added but it will recreate the automatic constraints from the current control positions. I found this helpful on occasion just to do a reset, either after moving controls in the view or unsuccessful experimentation on my part.
I admit, these observations are from my early experiences using the feature – please correct me if I’m mistaken on any of these items here!