iPhone App Without NIBs

There have been numerous times when I have HATED Interface Builder. It can be a pain to launch when all you want to change to change is 1 little thing in an NIB. It can be extremely slow. If you change 1 thing you have the risk to have to reconnect all Outlets and Actions and there have been times when I spend hours making the view in Interface Builder and when I want to do something that Interface Builder does not support I have to create my own custom view from scratch. I have decided to avoid Interface Builder completely, unless I absolutely have to and I am not regretting my decision at all. I am now starting all of my new projects without a single NIB and I have an incredible amount of control now. Here is how to set up a iPhone app with out any NIBs.

**PROJECT is the name of you iPhone project.

1) Delete MainWindow.xib

2) Open Info.plist and remove the line that says “Main NIB File base name”

3) In main.m change

int retVal = UIApplicationMain(argc, argv, nil, nil);

to

int retVal = UIApplicationMain(argc, argv, nil, @"PROJECTAppDelegate");

4) Create the window that was in the NIB as soon as the application launches by adding this code to the beginning of the applicationDidFinishingLaunching: method

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

Thats it! Now you don’t need a single NIB file in your project.

Happy Coding!

你可能感兴趣的:(iPhone)