0

I have a feeling about iOS development on which I would like to get feedback.

Storyboard / Interface Builder are, at first glance, awesome tools. The truth is that aside quick prototypes and really simple user interface I always feel blocked using them. This question offers probably a good example: how can I use one storyboard for 4" and 3.5" iphone screens with autolayout (ios6 + ios7)?

I am considering to code all my views. Mostly because it will let me implement some logic, like equal spacing of elements. Something that is, AFAIK, impossible to do in a cross device fashion through the GUI tools.

My questions are: Does Storyboard / IB support advanced view layout? How do you usually code your view if you do so: extending UIView / tweaking the controller?

EDIT: the accepted answer link is nice. Interested readers could also look at Apple's Auto Layout Guide relevant example: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutbyExample/AutoLayoutbyExample.html#//apple_ref/doc/uid/TP40010853-CH5-SW7

Cœur
  • 37,241
  • 25
  • 195
  • 267
AsTeR
  • 7,247
  • 14
  • 60
  • 99
  • This question is really too broad for a single answer. Is there a specific advanced view layout that you wish to support that you cannot figure out how to create in IB? Note that Xcode 6 brings new features to storyboards not address in that question. – Kevin Nov 14 '14 at 16:11
  • 1
    You can do equal spacing in the storyboard, but you need to add spacer views between your views to accomplish this (I think that's the best way to do it in code too, if you're supporting multiple screen sizes). As for your previous question, the easiest way to do that would be make IBOutlets for the top constraint and the height constraint, and change their constant values in code (so a hybrid approach of storyboard and code). The storyboard can support quite advanced layouts, but every case is different, and you have to decide which works best for you. – rdelmar Nov 14 '14 at 16:25

2 Answers2

1

Previous to iOS 8 it was much harder to build complex layouts using Interface Builder. You were essentially limited to stretching or pinning to edges. Now you can build layouts that adapt to size classes and change their layouts or constraints based on the width and height of your device.

That being said, even in really difficult scenarios that IB can't handle, I still end up building chunks of views in XIBs and then laying out those chunks manually.

TLDR; Interface Builder is going to be helpful 99.9% of the time as long as you know how to use all its features.

InkGolem
  • 2,662
  • 1
  • 15
  • 22
1

http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial

Ray gives a decent starting guide on how easy it is to create a single adaptive view now, which has caused me to switch from being completely programmatic.