Those Damn AutoLayouts
Far from me to say that they’re just: shit. But I’ve got to confess that I’ve been struggling with them, and in the end after wasting 1-2 days each time trying to figure out what’s wrong, resorted to disabling the AutoLayout and adjusting the UI manually. Most of the code I write nowadays has a global variable CGFloat adjustForGiraffe = 44.0f. So, my feeling at the moment is: they are a bag of pain.
Anyway, just to document what I proposed in that discussion: I believe that most of the confusion comes from the poor UI for constraints in Interface Builder. Here’s an alternative, that should prove very handy:
- Xcode generated constraints: color them yellow, 1pt thick
- User promoted constraints: I mean, call them what they are, ie. user constraints: color them blue, 2 pt thick
- over-constraints: that’s the nugget, the one piece that is missing and that fails 99% of the time! Color them red, so that we can see in a sec where the problem is.
I should insist about that last point. Most CAD software I have used have some sort of visual clue when doing dimension-driven and computed constraint design development. Use just the same approach, and we should be fine…