Tuesday, November 10, 2009

Add TextView using Interface Builder

Interface Builder is a visual design tool you use to create the user interfaces of your iPhone OS and Mac OS X applications. Using the graphical environment of Interface Builder, you assemble windows, views, controls, menus, and other elements from a library of configurable objects. You arrange these items, set their attributes, establish connections between them, and then save them in a special type of resource file, called a nib file. (The term “nib” is historical and is an acronym for “NextSTEP Interface Builder.“) A nib file stores your objects, including their configuration and layout information, in a format that at runtime can be used to recreate the actual objects

Expand Resources in Groups & Files on the left, double click HelloWorldViewController.xib to open it in Interface Builder.


There should be three windows opened similar to that shown below:

(If you can't see the window of Library, it can be opened by Tools->Library from Top Menu of Interface Builder.)

Here, I want to place a text on the screen only:
Scroll down from Library, until you see the object TextView, drag it into View window. It can be edited, moved and resized... Change the text to "Hello World".


Save it.

Switch back to Xcode and click Build and Go button.


So simple!

Note: Interface Builder generate XML only, it will not generate any functional code.