Search code examples
ios5ios6iphone-5

How to transist app from ios5 to ios6 (3.5' display to 4' display)


Currently, I need to convert iOS application from iOS 4.0 (3.5 inch display) to iOS 6.0 (4 inch display).

  1. Please suggest me the easiest way for how to make an iOS older verion (5.0 and older) application compatible with ios6 and iPhone5.

  2. Help me for how to set frames of UI objects of 3.5 inch XIB's for 4 inch XIB.

  3. If any one has a good tutorial or article related to this topic then please provide me link.


Solution

  • You should use following code for detecting ios6 and iphone 5 and after distinguishing perform necessary changes as required.

    to conform to version specified in system defines

    //#define __IPHONE_2_0 20000
    //#define __IPHONE_2_1 20100
    //#define __IPHONE_2_2 20200
    //#define __IPHONE_3_0 30000
    //#define __IPHONE_3_1 30100
    //#define __IPHONE_3_2 30200
    //#define __IPHONE_4_0 40000
    

    //#define __IPHONE_6_0 60000 You can write function like this ( you should probably store this version somewhere rather than calculate it each time ):

    + (NSInteger) getSystemVersionAsAnInteger{
    int index = 0;
    NSInteger version = 0;
    
    NSArray* digits = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
    NSEnumerator* enumer = [digits objectEnumerator];
    NSString* number;
    while (number = [enumer nextObject]) {
        if (index>2) {
            break;
        }
        NSInteger multipler = powf(100, 2-index);
        version += [number intValue]*multipler;
        index++;
    }
    return version;
    }
    

    Then you can use this as follows:

    if([Toolbox getSystemVersionAsAnInteger] >= __IPHONE_6_0)
    {
      //blocks
    } else 
    {
    //oldstyle
    }
    

    After determining version of OS use following steps for transition.

    1. Set a 4-inch launch image for your app. This is how you get 1136px screen height (without it, you will get 960px with black margins on top and bottom).
    2. Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly.
    3. If you didn't, adjust your view layouts with proper auto resizing masks or look into Auto Layout if you only want to support iOS 6 going forward.
      1. If there is something you have to do for the larger screen specifically, then it looks like you have to check height of [[UIScreen mainScreen] bounds] (or applicationFrame, but then you need to consider status bar height if it's present) as there seems to be no specific api for that.

    Example:

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
     // code for 4-inch screen
    }else{
     // code for 3.5-inch screen
    }
    

    Thanks.