News for hackers. Stuff that matters.
Re:Behind enemy lines: 3 months as an iOS developer at Google by _stephan on Thursday January 03, 2013 @08:48AM (#5002290)
Using code for layout has several advantages:

- easier version control and code merging

- you don't need Interface Builder to review the layout code

- code is easier to search, e.g. for the use of certain controls (Xcode doesn't support searching XIB files)

- code can be parameterized (you can e.g. use global constants for font sizes, colors and margins)

- layouts that follows certain rules (fixed heights and margins etc) are sometimes easier to build with code, especially when the number of visible controls is variable or some controls are only optionally displayed

- you can easily refactor aspects of the layout into reusable components (i.e. functions or classes)

Re:Behind enemy lines: 3 months as an iOS developer at Google by cageface on Thursday January 03, 2013 @09:02AM (#5002355)
I'm a big fan of declarative layouts and vastly prefer doing Android UIs to iOS UIs for this reason. But that's only because Android has a sane & powerful layout language. Obj-C is so hideously inflexible and verbose for this kind of thing that I prefer to stick to xibs despite their limitations.

Of course there will always be cases in iOS apps where layout in code makes more sense though.

Re:Behind enemy lines: 3 months as an iOS developer at Google by bjustin on Thursday January 03, 2013 @10:53AM (#5002844)
AutoLayout (new in iOS 6 and OS X 10.7) is decidedly OK to use in code or in IB.
Re:Behind enemy lines: 3 months as an iOS developer at Google by bennyg on Thursday January 03, 2013 @10:29AM (#5002727)
I'm of the "do both" camp. Personally, I like starting out the interface in .xib because of the wysiwyg style - I've been an Illustrator and Photoshop design guy for much longer than I've worn my iOS Dev Hat. By laying out areas of apps in subviews of the main view, then manipulating those in code, I get very easy content sizing (3.5" vs 4" screen) without using the springs/struts and the terrible iOS6 autosizing constraints, and animations couldn't be easier.

Just looking through my open projects right now, all of my ViewControllers have a buildUI method right under ViewDidLoad.

Re:Behind enemy lines: 3 months as an iOS developer at Google by cageface on Thursday January 03, 2013 @10:41AM (#5002778)
Glad to hear I'm not the only one that thinks that the new iOS 6 auto layout stuff is a train wreck. The WWDC sessions on the subject are like Onion parodies of normal tech talks.
Re:Behind enemy lines: 3 months as an iOS developer at Google by mikec3k on Thursday January 03, 2013 @01:42PM (#5003821)
I'm starting to prefer using code for layout, since it does make some things easier. When I inherit a large project, it's nice to be able to search & easily change stuff in code rather than having to tweak lots of xibs.