PDA

View Full Version : Moving to Cocoa Touch Interface Builder




rendezvouscp
Mar 27, 2008, 07:41 PM
Hello. My apologies for being a newbie when it comes to Xcode/Interface Builder.

Like many, I've been building my iPhone app and now would like to finish the interface in Interface Builder. What is the best way to take the interface I already have (and the associated code with it) and move to Interface Builder?

Thanks in advance.



SqueegyX
Mar 27, 2008, 08:27 PM
I've updated my plist, and created a nib (is it supposed to be an empty nib?, window nib?), but sadly I have no UIKit controls in my library.

Definitely running the new XCode. What am I missing here? Is there supposed to be an iPhone view nib template that I am not seeing somewhere?

ace2600
Mar 27, 2008, 09:34 PM
To create the iPhone interface and not the mac one, I went into Interface Builder directly and created a new template under the Cocoa Touch tab. This gives the UIKit controls.

However, this is as far as I can get. I can only save the file as a XIB, not a NIB. If I save it to a new Xcode project (as say MainWindow.xib) and add MainWindow to plist like the FAQ's say, it still ignores my MainWindow.xib file. I assume that's because AppDelegate creates a window and view on it's own and has no way of talking to MainWindow.xib.

I am very curious on the steps required to use the nib/xib from a new Cocoa Touch project. Is there any tutorials or information on the Interface Builder for this aside from the brief Interface Builder release notes? I know it's brand spanking new, but Apple launched several tutorials for the launch of Beta 1.

rendezvouscp
Mar 28, 2008, 12:05 AM
I'm still puzzled and I've yet to come across anyone who knows what they're doing *and* will share. :(

ace2600
Mar 28, 2008, 01:38 AM
Google Blog search sort by date is my newest friend...

Here is a very brief tutorial on how to create an iphone app with Interface Builder:
http://techblog.muthuka.com/index.php/2008/03/27/hello-world-iphone-native-application/

The key part is changing the AppDelegate.m function to this:- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create window
self.window = [[[NSBundle mainBundle] loadNibNamed:@"MainWindow" owner:self options:nil] objectAtIndex:0];

// Show window
[window makeKeyAndVisible];
}Not much, but it's the start I needed.

zippyfly
Mar 28, 2008, 07:36 AM
I'm still puzzled and I've yet to come across anyone who knows what they're doing *and* will share. :(

Intrigued... you mean you reckon people don't want to share for fear of even more competition in the iPhone arena?

If so, that's kind of narrow minded. The iPhone arena is ALREADY going to be overcrowded. Surely you got to know that every Joe and his dog is trying to program for the iPhone, from California to Korea.

The faster all of us gets to be proficient, the more resources there will be to help each other out, is what I think.

kainjow
Mar 28, 2008, 07:44 AM
Intrigued... you mean you reckon people don't want to share for fear of even more competition in the iPhone arena?

I could give you full examples of how to do all this stuff but everyone agreed to the NDA when you installed Xcode and I don't want to break that. So I just give out vague/general information on normal Cocoa that is already public, or I link to someone else who already brought it public. But I really think Apple doesn't care too much, it's just to protect them if something were to happen. If you Google you'll find tons of other forums and sites where they're discussing details of the SDK as well (even Apple's own discussions!).

This is why I recommended from the start to learn normal Mac Cocoa first since you can find easy help on every topic, and all that knowledge transfers over to the iPhone. If you're learning programming for the first time with the iPhone it'll be annoying and not easy because you are not the SDK's target audience and the documentation doesn't walk you through everything.

Sbrocket
Mar 28, 2008, 08:58 AM
This is why I recommended from the start to learn normal Mac Cocoa first since you can find easy help on every topic, and all that knowledge transfers over to the iPhone. If you're learning programming for the first time with the iPhone it'll be annoying and not easy because you are not the SDK's target audience and the documentation doesn't walk you through everything.

The second part is definitely on the money, but I'd attach a qualifier to the first part just to clear it up for people that might be reading it - Mac OS X Cocoa is not Cocoa Touch. There are changes that you'll have to adjust to like the lack of bindings or, for now, the rather raw nature of the iPhone SDK as a whole. Despite the differences and especially if you're new to Objective-C or Cocoa, its much easier to start with OSX and adjust to the differences later. People would probably do well to not rely on Interface Builder so much (like I started out doing :o). I'm not saying don't use it, but be use you can do what IB makes easy in code alone.