top of page
  • Writer's pictureJennifer Eve Vega

Creating our Own MainWindow.xib for Xcode 4.2

MainWindow.xib file is no longer seen in Xcode 4.2. And this is one of the important things a developer should know especially if the developer wants to create UI using Interface Builder.

Let\’s start!

Create a new Xcode project

Choose Empty Application

Add a Project Name, Company Identifier, for now, let\’s use iPhone as our device family, others are optional.

Choose a directory where you would like to save your work.

Add a New File.

Click \”iOS\” category, scroll down and choose an Empty .xib file.

Choose the same Device family from the one you have chosen a while ago when you created your project.

You may name this .xib file anyway you want, but let\’s just name it \”MainWindow.\”

On your MainWindow.xib, click the \”File\’s Owner,\” the yellowish box on the left side. Click the Identity Inspector, the third button found on the upper part of the Utilities Panel. Change its Class to \”UIApplication.\”

Search for \”Object\” in the Objects Library.

Drag it to the \”Placeholder/Objects\” Panel, the same line with the yellow and reddish box.

Click the dragged Object, and change it\’s class to your AppDelegate Class.

Search for a Window Object in the Objects Library, drag it to the Placeholder/Objects Panel.

Right-click File\’s Owner (yellowish box), connect the \”delegate\” outlet to the AppDelegate Object (yellow box).

Go to AppDelegate.h, add \”IBOutlet\” to your UIWindow property. Go back to MainWindow.xib, right-click AppDelegate Object, and connect the \”window\” variable to the Window Object added a while ago.

Click the .xcodeproj file, go to Summary tab, under iPhone / iPod Deployment Info, change the Main Interface to the name of your .xib file. In our example, MainWindow.

Lastly, open AppDelegate.m, under applications:didFinishLaunching:withOptions function, comment out all the codes, but leave these codes:

[self.window makeKeyAndVisible];

return YES;

You may add UILabels or UIButtons on your window object in Interface Builder, to check that you have successfully connected and created your own MainWindow.xib. You should see your drag and dropped objects when you run it in your simulator.

Done! 🙂

#MainWindowinAppDelegate #Xcode42 #MainWindow #MainWindow #iPhone #InterfaceBuilder #CreateMainWindow #iOSTutorial #mobile #Xcode #iOS

1 view0 comments

Recent Posts

See All

Hi Everyone! It has been a very long while since I last posted in this blog. This time, I will be making a tutorial in using blocks when we are accessing our API or web services. Disclaimer: I am also

Post: Blog2 Post
bottom of page