3 ms·
XIBs and programatic layout is the Vim vs Emacs of the iOS world. There are a lot of pros and cons of both. I used to spend a not insignificant amount of time
by objclxt 14y ago
XIBs and programatic layout is the Vim vs Emacs of the iOS world.
There are a lot of pros and cons of both. I used to spend a not insignificant amount of time trying to moderate debates between iOS engineers who favoured one approach versus the other.
Doing all your layout in code isn't inherently bad, and there are lot of Apple written apps that do this (conversely, some of the newer iOS built-in apps do use NIBs). The main problem that I've found with layout entirely in code is that whilst it's fine for you, the sole developer, once you bring in more people onto the project you can have
problems with getting people up to speed on what exactly is going on where.
Of course, the solution to this is to enforce strict coding standards over how to layout the views themselves in code, which Google clearly do. And as the article points out, resolving merge conflicts in code is somewhat more enjoyable than in nibs.
That said, just as programatic layout isn't inherently bad, neither is leveraging interface builder strategically. Here's a good example: iPhoto on iPad has a completely custom interface that's mainly laid out programatically, but certain key elements are actually composited together in IB. For example, the brushes that slide up when touching up photos are being brought in from NIBs, but animated and manipulated in code. Using the nib file to load in the images reduces the code without sacrificing understanding (or at least, that's Apple's argument. There's a fantastic WWDC 2012 session that covers how the iPhoto UI is put together in more detail).
The TLDR; - the only risk of programatic layout that I see if developers going 'off piste' and laying out in a non standard way. With the right coding standards you should be fine.
- cageface 14y agoXIBs and programatic layout is the Vim vs Emacs of the iOS world. To me that implies that one essentially makes the other redundant but I prefer to see them as two powerful tools in my box that each have their uses. I've always thought the people that insist on doing everything in xibs were a little weird but going too far the other way doesn't make sense to me either.
- objclxt 14y agoYou're right, it's a pretty bad analogy! I was more going for the whole NIB/Code debate being something that's never going to be adequately resolved.
- Aqua_Geek 14y agoSome of Apple's apps do their layout in code because the necessary features weren't available in Interface Builder yet (think of things like collection views, etc).
- morty16 14y ago> There's a fantastic WWDC 2012 session that covers how the iPhoto UI is put together in more detail). Do you happen to know the session name or number?
- jsanz 14y agoThe session name is 'iPhoto for iOS: UI Progression and Animation Design'. It's under Essentials.
- julien_p 14y agoProbably https://developer.apple.com/videos/wwdc/2012/?id=243 https://developer.apple.com/videos/wwdc/2012/?id=243 I haven't watched it yet, but it's been on my to-watch list for a while now.
- objclxt 14y agoSure, sorry - I should have put that in my original post. It's Session 243, iPhoto UI Progression and Design, with Randy Ubillos himself.