• Latest News

    Powered by Blogger.
    Saturday, April 26, 2014

    iOS - Universal Application


    iOS Universal Application,

                                                                                           

    Steps Involved

    1. Create a simple View based application.
    2. Change the File name ViewController.xib file to ViewController_iPhone.xib as shown below in the file inspector in the right hand side.
    iOS Tutorial
    3. Select File -> New -> File... then select the subsection "User Interface" and select View. Click Next.
    iOS Tutorial
    4. Now select the device family as iPad and click next.
    iOS Tutorial
    5. Save the file as ViewController_iPad.xib and select Create.
    6. Add a label in center of screen in both ViewController_iPhone.xib and ViewController_iPad.xib.
    7. Now in ViewController_iPad.xib select the identity inspector and set the custom class as ViewController.
    iOS Tutorial
    8. Update the application:DidFinishLaunching:withOptions method in AppDelegate.m as follows
    iOS Tutorial
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; } else{ self.viewController = [[ViewController alloc] initWithNibName: @"ViewController_iPad" bundle:nil]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; }

     9. Update the devices in project summary to Universal as shown below.

    Output

    Now when we run the application we'll get the following output.

    When we run the application in iPad simulator we'll get the following output.


                                                                       

    • Blogger Comments
    • Facebook Comments

    0 comments:

    Post a Comment

    Item Reviewed: iOS - Universal Application Rating: 5 Reviewed By: Unknown
    Scroll to Top