I'm currently studying the difference between storyboard, xib, and custom code and I'm confused on what should I use for my app development. My question is, is it okay to combine Storyboard, XIB and custom code in one project? Is there any possible problem regarding to performance issue and memory leaks if I use the three?
-
2Possible duplicate of [Which is more efficient way? StoryBoard or XIB?](http://stackoverflow.com/questions/22524232/which-is-more-efficient-way-storyboard-or-xib) – Muhammad Adnan Aug 19 '16 at 04:25
-
Check my answer raizencelf – user3182143 Aug 19 '16 at 04:35
3 Answers
It is 100 percent possible to use all those things in your ONE PROJECT.First you need to know about the difference
iOS Storyboards: A visual tool for laying out multiple application views and the transitions between them.
NIBs (or XIBs): Each NIB file corresponds to a single view element and can be laid out in the Interface Builder, making it a visual tool as well. Note that the name “NIB” is derived from the file extension (previously .nib and now .xib, although the old pronunciation has persisted).
Custom Code: i.e., no GUI tools, but rather, handling all custom positioning, animation, etc. programmatically.
iOS User Interfaces: Storyboards vs. NIBs vs. Custom Code
Benefits of Storyboard vs XIBs
1.Can prototype UITableViewCells directly inside the Storyboard itself.
2.Can define static UITableView sections and rows.
3.Can use auto-layout to add constraints to the topLayoutGuide and bottomLayoutGuide.
4.Can specify navigation and transitions (that’s one of the main purpose!).
5.Can define multiple “screens” (UIViewControllers) in a single place (no need of multiple XIBs).
Inconveniences of Storyboards vs Code & XIBs
1.Storyboard are large files: slow to load sometimes.
2.Requires a big screen to display all (or even partial) content.
3.Easily breakable when merging (Git) .
4.High probability to break it when merging (Git) as Storyboards contains lot of information.
5.Lots of warnings when supporting iOS 7 and iOS 8 (margins, size classes).
6.Cannot reference (or include) other XIBs.

- 9,459
- 3
- 32
- 39
Yes, it is possible to combine Storyboard, Xib and custom code in a project. Try to do most of the work in storyboard, so that we can reduce code.. XIB's are helpful in some cases, for example, to show custom alerts.

- 1,699
- 15
- 22
Have had projects using all 3. More specifically, tableview cells on their own xib, but the tableviewcontroller on storyboards, and other random viewcontroller on code completely.

- 585
- 1
- 4
- 17