iPhone + Interface Builder

April 8, 2008

Note: The Pages o’ Peat have moved to http://peat.org/ — please update your bookmarks and references accordingly. Thank you!

Note: This is a little out of date, since the Beta 3 build automatically generates an empty XIB and the code for including it in new projects. If you’re looking for Apple’s introductory tutorial on how to build applications with Interface Builder, click here.

So, the trick to using Interface Builder is figuring out where to put the files, and plugging the XIB interface into the app.

The file question is easily answered:  File > Write Class Files to the directory in your project where the rest of your classes live.  For really simple apps with a single view, select your existing AppDelegate class and IB will merge the changes for you. You’ll also see a new .xib file in your classes directory, containing your interface.

Connecting the XIB interface is also relatively straight forward.  In your AppDelegate file, change what self.contentView points at:

self.contentView = [[[NSBundle mainBundle] loadNibNamed:@"XIBFileName" owner:self options:nil] objectAtIndex:0];

Where XIBFileName is the name of the generated XIB file without the .xib extension.

Anyhow. I’m still learning, and this is with a beta release of the iPhone SDK, so you’re welcome to leave comments if you have better ideas or tips on working with IB for the iPhone. Thanks!
 

 

About these ads

5 Responses to “iPhone + Interface Builder”


  1. [...] iPhone.  Can someone point me at an example? I found a step-by-step example here and posted my own followup summary for people who are already familiar with Interface Builder, and just want to see how to plug in [...]


  2. I’ve built a few “Hello World” applications for the iPhone, but I’ve yet to see Interface Builder actually working correctly. You can build your interface with no problem, but hooking in actions to events does not yet seem to be supported. Have you found this to be true, or have I totally missed something?

  3. Peat Says:

    @jason – The example Apple provides that I’ve linked to at the top of the post shows off the basics — connecting actions and events and whatnot. It’s still a little rough around the edges (as of Beta 3), but it works!

    Beta 4 is out. I haven’t had any time to play with it, though!


  4. Off topic – Help with PM?
    lost password
    Boss Resurfacing
    Boss Resurfacing

  5. Crystal Says:

    Fortune 1000 companies each spend an average of $2 million per year on site redesigns, without knowing if the redesign made the site easier to use.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: