Interface Builder alternate

Discussion in 'iOS Programming' started by sagarshivam, Jun 27, 2011.

  1. sagarshivam macrumors member

    Joined:
    May 24, 2011
    #1
    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
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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).
     
  3. amorya macrumors 6502

    Joined:
    Jun 17, 2007
    #3
    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.
     
  4. sagarshivam thread starter macrumors member

    Joined:
    May 24, 2011

Share This Page