Hacker News new | ask | show | jobs
by ktran03 4205 days ago
I struggled with those, but after a few years doing iOS dev, it isn't so bad. It all eventually sticks.

And autolayout is freakin awesome imo, though I hear a lot of people groak about it.

2 comments

Autolayout is horrible in the sense that when something isn't working, it's really hard to figure out what went wrong. My personal favourite is when you forget to set translatesAutoresizingMaskIntoConstraints to NO on a container view. A whole bunch of implicit constraints pop into existence that conflict with your actual programmed constraints, and the error message that tells you that you have constraint conflicts really doesn't help you in figuring out where the constraints are coming from. Eventually you figure this out, and you don't get caught out by it any more, but in the learning phase, it's quite painful.

Something else I really dislike when it comes to constraints - they don't play well with animations, at least in my experience. I recently created a view that had a variable number of square buttons in it that were laid out in a grid two rows high. Making a nice animation when you add a new button, fading in the new button, and sliding the others out of the way was nigh on impossible (ie 'not possible without writing more code than if I had just done the layout manually). And yet, this seems to be the perfect use case for auto layouts...

This is exactly why I don't use it. I do iOS development since the first SDK public release, I have a love/hate relationship with Interface Builder. I used to use it a lot, but now I use it only in small projects. Storyboard is awesome for small apps.

But for my big projects I do 100% of the UI in the code, if the UI use a lot of custom control, it just not worth it to use IB, the end result is that what you see is not at all what you get. BUT it improved a lot with Xcode 6, because now it can render custom views live in Interface Builder.

Auto layout on the other side.... it's just broken.... Every time I try to use it I got what you mentioned in your first paragraph. And I do a lot of animations in my apps, and playing with 10 constrains instead of a simple frame is just .... too much of a burden.

Again, for big custom apps I don't use it, but I love those functionalities for small & simple apps.

It's really, really nice for making static layouts in IB, but as soon as you do anything dynamic — programmatic views, animations, etc. — the whole thing becomes a burden.

I often wish we had something akin to autolayout for CSS.

Still hasn't become "not so bad" for me after many years.