Reputation: 1692
I am curious to know if anyone has any experience comparing the load time performance of iPhone apps with views laid out in NIBs vs. views laid out entirely programmatically (here is a similar question).
Is there really any advantage of views laid out entirely programmatically over views laid out in NIB ?
Upvotes: 4
Views: 2234
Reputation: 3399
IMO a mix of both would be the right choice. Using interface builder for defining the basic layout (i.e a xib that doesn't change much over time) and default options of views and for the rest can be done programmatically (specific tweaks and effects). This should solve the source control and performance problems to some extend.
Although once we start off creating views programmatically ,we continue doing it for every time not realizing that the same thing could be done with much less effort in Interface Builder. After all if it's a GUI we are building it's better to have a visual reference.
Upvotes: 2
Reputation: 317
When I was beginning to learn iOS programming, I was building UI in xib file. But when I had developed some projects, I began to just write code to implement my UI.
There are some benefit through building UI programmatically:
First, by writing code, you have the view hierarchy clearly in you mind, and the view hierarchy can be important to efficiently implement your UI.
Second, if your UI is complicated, for example, with some animation or transform, you will benefit quite a lot from coding UI. Even sometimes you may not use UIView to build UI, you may use CALayer to accomplish some effect, which can not built by xib file.
Furthermore, when you get used to building UI programmatically, you will love it, because you can just code in the .m file and has no need to worry about the xib file.
However, if you are just a beginner in iOS programming, just fine to get start with xib file.
(Apple now provide StoryBoard, I have not learned about it, you may learn it to find if there is anything new.)
Upvotes: 2
Reputation: 25907
There are some advantages by doing it on code:
With nib:
About performance, you can actually check this.
Upvotes: 4
Reputation: 1843
According to Apple, XIB file loading time is longer than build UI programmatically. Saw that in a WWDC lecture.
If performance is what counts, build your UI in code and not in IB.
Upvotes: 6