Saturday, October 3, 2015

LONG LIVE XIBs!!!! Create an iOS app without storyboards in XCode

Are you one of those devs who don't like Storyboard? I didn't even bother to learn about Storyboards and how to use them. Call me stubborn noob that's ok. But I am so used to programmatically create things on XCode so storyboards are not my thang.

So how do you do this with latest XCode? If you go to New Project LO AND BEHOLD no such thing as a project without storyboards. All of them has storyboards. Unless you go with the absolute empty project.

What I will show you is how to select a Single View Project and then make it run without Storyboard. Let's go! First go to menu File -- New -- Project... and select Single View Application. Then follow the following steps: 

Well, obviously, first thing to do it is to delete the storyboard!

2. Delete the "Main" text in Main Interface under General Tab in the target.

3. Right click your project in the left panel and select New File... and goto iOS - User interface - View and click Next. Give the xib name "ViewController" (basically same name as your viewcontroller.m and h).

4. Click on your newly created XIB file. Click on the File's Owner (yellow box), then click on the Identity Inspector tab, and type "ViewController" in the Class field.  (see the red boxes highlighted in the image below)

5. Then click on the View part of XIB file and click on the  Connections Inspector tab and connect the Referencing Outlet to the File's Owner and select "view".

6. Click your AppDelegate.h, and add these codes:

(see the red box highlights).

6. Then click on AppDelegate.m and add these codes in the appDidFinishLaunching method:

That's all and you should be able to run the app and it will show an empty white View.


1 comment:

  1. This comment has been removed by a blog administrator.