iPhone Development: Interface Builder -Read the Damn Release Notes!
Mar/Mon/08 19:07 Filed in: iPhone SDK
I was glad that Interface Builder was included in the
second drop of the iPhone SDK as I like the feedback
of seeing the views as they are laid on the screen.
I dove into IB and started using it just like
one might for Mac OS X, create a window, drop in a
Table View add a Navigation View set up the
corresponding controllers and sure enough when I
added a bit of code to my iPhone app, it saw the
table view in the simulator. But when I went to
navigate to the next view it didn't work.
Sigh. "I must have something connected
wrong in IB" I said to myself and spent many hours
connecting outlets and trying everything that might
make sense. Nothing worked.
What to do?
Since there was no iPhone example application using IB, I was on my own and started digging around. I first realized that the UINavigationController as setup by the nib loading process was missing a few initialized objects as compared to one initialized with initWithRootViewController. Hmm... OK, so I ditched the nib based UINavigationController with one I created and initWithRootViewController. "That should help", I thought. Ah... no. I better try to find more about IB and iPhone. So I reread the release notes and sure enough, right there in front of my face was the answer:
Well, OK. To be fair to me, when I first read this I was not thinking that I defined the UI by dragging and dropping views onto a view controller UI thingy. When I did, cha-ching! it worked.
What to do?
Since there was no iPhone example application using IB, I was on my own and started digging around. I first realized that the UINavigationController as setup by the nib loading process was missing a few initialized objects as compared to one initialized with initWithRootViewController. Hmm... OK, so I ditched the nib based UINavigationController with one I created and initWithRootViewController. "That should help", I thought. Ah... no. I better try to find more about IB and iPhone. So I reread the release notes and sure enough, right there in front of my face was the answer:
FAQ: How do I edit a Cocoa Touch view controller? ▪ Drag a view controller object from the library into the document window. ▪ In the document window, double-click the icon for the view controller object to open its editor. ▪ Drag and drop views, navigation items, and tab bar items from the Library onto the editor.
Well, OK. To be fair to me, when I first read this I was not thinking that I defined the UI by dragging and dropping views onto a view controller UI thingy. When I did, cha-ching! it worked.