Storyboard versus this in code

I work for a company where we have several iOS developers, and we use GIT to work together on the same projects. We never use Storyboards or .xib files in our development process, since it is almost impossible to merge them correctly.

With the introduction of iOS7, I thought about the fundamental differences between Storyboards and coding the entire user interface โ€œthe old wayโ€ without using Interface Builder.

Is there anyone here who does this? And most importantly, is there something you can do in storyboards that you cannot do in Xcode 5 code?

+8
ios iphone cocoa-touch xcode ipad
source share
3 answers

I am going to split your question into two: NIB and storyboards.

Regarding NIB, source control problems can be painful, but manageable, mainly because you usually have one NIB file for each view controller. You can imagine a situation where you have two developers working on two different sections of your NIB application without any association problems. The rocks are different, since you have one file that describes the majority (if not all) of the user interface of your application. Obviously, there is much greater potential for conflict resolution.

NIBs can be extremely useful and save time if used correctly. Here's an example: iPhoto App on iPad has a very sophisticated interface. The vast majority of this user interface is represented programmatically. However, the application also uses NIB to load graphic elements, which are then laid out in the code. This is how the brush panel works โ€” all brushes are created in NIB. This means that Apple should not have dozens of identical images / images. All creation can happen in the NIB (this was discussed in detail at the WWDC 2012 session on iPhoto UI - it's worth tracking).

Thus, NIBs are sometimes good, can save you a lot of time, and while there are merge problems, they are in many cases easy to manage and handle.

Then we come to the storyboard. Storyboards are interesting. On the one hand, they are extremely useful and useful for simple applications and developers new to the platform. I just converted a UINavigationController based application from NIB to storyboards and found significant time savings (especially around table views, since you can use prototype cells with the storyboard).

However, if you are working on a large-scale project with several developers, Iโ€™m not sure if storyboards are beneficial. There are, as you say, big problems with merge conflicts, and unlike NIBs, itโ€™s not easy to resolve them, because one storyboard file controls your entire application user interface.

Here's what I propose (and feel free to ignore me!) - if you are currently developing applications and fully implementing your layout / user interface in code, consider whether NIB can save you time. They may not be - they are not for everyone, but it is worth at least considering it. You may be surprised at how many large applications actually use NIB (iPhoto, as I mentioned, as well as many built-in applications provided by Apple, as well as many popular third-party applications with large teams). I probably will not consider storyboards unless you are the only developer working on an application with fairly simple navigation. This does not mean that you are not doing down storyboards - I love to use them - it just is not suitable for collaboration.

Someone posted this comment in response to your question - I wanted to discuss it:

You cannot do anything in the storyboard and you cannot do in the code. Objects, gesture recognizers, segues, even restrictions - all available for you to programmatically create

This is technically true, but there are actually things in storyboards / NIBs that are much simpler than code. A good example of this is auto-layout. Despite the fact that you can certainly completely control the automatic layout contours in your code, the harsh reality is that the ASCII auto layout view is much more complex than the visual representation you get in IB. This is especially true on Xcode 5, where car routes have improved significantly in IB (I canโ€™t talk about this in detail, since it is still under the NDA, but Apple speaks a little about changing here ).

+11
source share

For me, the only big drawback of storyboards is the slow loading time and the usual lag that comes when navigating a storyboard. I am not talking about 2-5 view manager applications. I'm talking about 10 or more ...

My personal preferences are small storyboards if I really need to use them (UITableView prototype cells) or just plain xibs.

Doing this only in simple code is just a question ... do you have enough time on your hands? :) Usually you wonโ€™t get much from this.

+3
source share

You should consider these issues in your field:

Development Time -

Obviously, working with the xcode user interface designer is much faster and easier to learn when creating new applications from scratch. Programmatically, you will need to determine in the code all the properties of each element that you want to set. Working with storyboards will make the development process much faster.

Code Reuse -

When working with the storyboard, you will have to bind the user interface elements to the controller using a bullet that will add additional hidden code to the storyboard file. When creating segments between the controller, the same butts are added. This hidden add code will make it harder to reuse controllers in other applications that you create. If you plan to reuse your controller code, then creating user interface elements is more appropriate.

Source Integration -

Conflict resolution is a common occurrence when several developers commit changes to a file. Creating and modifying user interface elements using the storyboard additional changes are added to the storyboard file, which sometimes makes conflicts resolvable. On the other hand, when changing user interface elements programmatically, only the changes you make will be added to the controller file.

+2
source share

All Articles