I’ll admit that this previous Cocoaheads Boston meeting got me thinking about Auto Layout again. I tried it in the past on my own and found it too different from springs and struts that I simply converted my ViewController to use those instead of Auto Layout a third of the way along. I just couldn’t be bothered.
Scrubbing the net for some information beyond the developer documentation given by Apple, I wanted to find a tutorial or two that was decent that could get myself better caught up. Yes UICollectionViews are next (saw them demo’d at WWDC), but let me get back on track.
I found a tutorial (in two parts because each is so full of information) on RayWenderlich by Matthijs Hollemans and they are extremely well done.
Matthijs has put a lot of effort into these tutorials and you can follow right along in your test Xcode project. I think that these two tutorials can go a very long way in getting you up to speed with Auto Layout and make it something you won’t despise or fear in the future. It obviously doesn’t always make sense to use it over springs and struts, but there are times when it can make your development layouts much, much more powerful.
Update. I’ve read both tutorials and I didn’t crack Xcode open to produce a test project. While the tutorials are quite good, they are relying on the use of Interface Builder to produce the results. It’s mentioned that to learn more about NSConstraints and their programatic use (ie. the truly desired method of developer interaction) to buy a book. I don’t mind that approach at all – after all he should be getting paid.
If you’re after some actual code in the implementation of Auto Layout, I’ve found a few tutorials that I list here:
- Dynamic Interfaces with Auto Layout
- Interesting keyboard use case
- Cocoa Auto Layout PDF from Apple (not iOS specific at all)
- StackOverflow question in regards to animating to new restraint
I am sure there are plenty of other places to find useful information in regards to Auto Layout. It’s a technology that isn’t exactly fresh any longer but perhaps needs a little more light shone upon it. It shouldn’t be this thing that you need to ignore or simply turn off without any more thought about it for new projects.