开发者

XIB files vs. defining layout in code in iPhone

Aside from the WYSIWYG editor, what are the advantages of using XIB/NIB files over defining the layout in code in iPhone/iPad/iOS?

While I don't find XIB files much useful,开发者_如何学C many iOS developers do, which makes me suspect I might not know their benefits or how to use them properly.


  1. Easier maintenance. More often than not, clients require last minute changes like changing the logo or changing colors or realigning something or some such. Much easier to change it in a xib file and see/show the results immediately
  2. Decoupling. It forces you to write nicely decoupled code right from the offset, which again means easier maintenance.


Defining things in Interface Builder makes them much easier to adjust later. Also, doing interface elements in code can lead to a lot of code bloat, for setting things like exact placement, font, color, etc.

The main advantage using code directly gives you is speed. But it's usually better to start in IB and then see what might need speeding up.

Table cells are one of the main areas where you might consider drawing elements in code for speed.


Personnaly, I'm using XIB to see graphically my I'm doing so I don't have to run, check the look, change a bit the color, run the app, check... It allows me to get a better design. If you work with designer that gives you photoshop design, it will not be useful for you.

Second thing : when you start to really handle Xib, it's much faster than doing it with code (but it takes time and training for TableView and tableView cell for example)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜