Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sagarshivam

macrumors member
Original poster
May 24, 2011
51
0
Dear All!

I am facing extreme difficulty while developing iPad/iPhone app in xcode (I am newbie for it). I found that interface-builder.app is getting crashed every time when I double click on it or double click any xib file.

Moreover for a "hello world" program, i removed xib file and adjusted accordingly in .m file and hello-world app worked well.

So as a temporary solution, I am not willing to use/create any xib file. I later found that xib is nothing but file written in xml.

Now, my question is that can I use objective-c code to create UI (simple only) so that I can save it as .m file instead of .xib file? I know it is not a good approach but this will solve my problem temporarily.

Kindly let me know the relevant link also.

Thanks in advance

Regards,
Sagar Priyadarshi
 
Now, my question is that can I use objective-c code to create UI (simple only) so that I can save it as .m file instead of .xib file? I know it is not a good approach but this will solve my problem temporarily.

There is no requirement to use IB at all. Both of the apps I have in the store create their UIs entirely in code (even drawing some icons in code where the icons are simple enough).
 
Well, as long as you know that solving the actual problem is the recommended thing to do… :)

To make an app without using a xib, you need to:

  • From your Info.plist, remove the "Main nib file base name" line
  • In your main.m, change the UIApplicationMain(argc, argv, nil, nil); call to include the class name of your app delegate class, eg UIApplicationMain(argc, argv, nil, @"MyAppDelegate");
  • In your app delegate class's application:didFinishLaunchingWithOptions: method, make sure you create yourself a window, as in the following code:

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
	self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
	[self.window makeKeyAndVisible];
    
	self.rootViewController = [[[RootViewController alloc] init] autorelease];
	
	[self.window addSubview:self.rootViewController.view];
	
	

	
    return YES;
}


This assumes that you have a UIViewController subclass called RootViewController.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.