3

I know this is a question that has been asked quite a bit, but it's iOS 9 and I still don't have a clear idea about what to do. For starters, here is what I seem to be surmising from all the data available:

  • Storyboards let you create segues. [I've never been a big fan of this answer because segues are often the least harrowing part of creating the UI layout for me.]
  • Xibs can let you create multiple top-level views. (Storyboards vs. the old XIB way) [I don't think I've ever used this much, though it seems rather helpful.]
  • Storyboards - Creating UITableViewCells is easier. [In my opinion, it's cleaner to create xibs for the cells and just invoke them in cellForRowAtIndexPath].
  • Storyboards can turn into one giant ultramassive file that is hard to edit. [I've seen this happen in practice and it is a big drawback, but at the same time...]
  • Storyboards let you arrange all your Views in one place with the layout shown as well. [This seems to be a big help for me. But then, over the years I've found doing this in code much easier. Which brings me to my final question.]

What is the performance aspect of both of these two things. My app is essentially the following :

  • A top level hierarchy of interconnected view controllers, not more than 5.
  • A large number of disparate, independent view controllers that range from Scroll Views to TableViews to static Imageviews.
  • Autolayout, size classes, the works.

For each of these view controllers, what is the performance of creating a storyboard for each of them vs. creating a xib for each of them. More importantly, what would be a good way to lay out an app like the one I've mentioned.

Community
  • 1
  • 1
gran_profaci
  • 8,087
  • 15
  • 66
  • 99
  • 2
    Separate Storyboards in iOS 9 can be linked together using Storyboard References in iOS 9 so you no longer have 1 "ultra-massive file" (unless you want to). Regardless, Storyboards seem to be the way to go and (more importantly) Apple seems to want them to be the default way to develop apps in iOS and OS X. – Robotic Cat Oct 12 '15 at 23:02
  • "I know this is a question that has been asked quite a bit" And it has been answered quite a bit, and nothing has changed. So there really is no need to answer it again. – matt Oct 13 '15 at 02:29
  • Possible duplicate of [When to use Storyboard and when to use XIBs](http://stackoverflow.com/questions/9404471/when-to-use-storyboard-and-when-to-use-xibs) – gran_profaci Oct 13 '15 at 04:48
  • Umm, well I'm asking for my particular case, where I have scenarios where Storyboards would be better and certain ones where xibs would be better, what would the performance implications be. I don't want to create storyboards for single views, but I don't want to clutter my code up with constraints. Sorry if I wasn't clear. – gran_profaci Oct 13 '15 at 04:55

2 Answers2

3

You definitely want to use storyboards for laying out view controllers - simply because you get access to topLayoutGuide and bottomLayoutGuide which the XIB editor won't give you.

For other views, it's a matter of preference. I tend to use XIBs for table view cells simply because I tend to reuse them on different screens and prefer to have them in their own files.

I would actually advise against manually writing view code where possible simply because it's much harder to read and work out how views are laid out, especially for developers who didn't write the code originally! For simple, dynamically sized things this can be fine, but if you're trying to lay out view controllers with different constraints depending on the size class it's going to end up a bit of a mess.

Yes, it's a pain to deal with merge conflicts of these files, but with iOS 9 you can split up view controllers into different storyboards a lot more easily using view controller references. Personally I find the inconvenience of merging storyboards/XIBs the lesser evil of having to write everything in code.

Jarrod Robins
  • 1,866
  • 2
  • 17
  • 23
1

It sounds like a Storyboard is the right thing for your current project. However, my experience has been that Xibs and Storyboards are problematic in the real world, for these reasons:

  1. extremely idiosyncratic from developer to developer, so it is tricky to build good storyboards as a team

  2. black boxes, so they require a tremendous amount of knowledge to master (unbelievable amount of hidden behavior). Only the most superficial semantics are covered in the documentation.

  3. internationalization is made much harder by being split up, especially if you have internationalized messages not contained in the Storyboard/Xib.

  4. backwards compatibility breaks annually / deprecation guaranteed over time. This is especially difficult if you try to maintain compatibility with older devices.

As soon as more than two devs started touching our code we rewrote everything to avoid Storyboards and Xibs altogether, and we became much more productive.

If you have to deal with any of those real world situations, I heartily recommend programmatically creating all of your views. There is even an app that makes this easier (and is way more scalable). I have no relationship with this company or product, but it is hands down a better solution.

http://www.paintcodeapp.com/

spirographer
  • 630
  • 4
  • 18