How to develop or migrate apps for iPhone 5 screen resolution?

后端 未结 30 3176
醉话见心
醉话见心 2020-11-21 05:48

The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels).

What is required to develop new or transition already existing applications

30条回答
  •  礼貌的吻别
    2020-11-21 06:02

    This is a real universal code, you can create 3 different story board:

    Set your project Universal mode, and set your main story iPhone with the iPhone5 storyboard and the ipad main with iPad target storyboard, now add new storyboard target for iphone and modify the resolution for iphone 4s or less now implement your AppDelegate.m

    iPhone4/4s (is the same for 3/3Gs) one for iPhone5 and make the project universal, with a new Storyboard target for iPad, now in to AppDelegate.m under the didFinishLaunching add this code:

        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
            UIStoryboard *storyBoard;
    
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width *scale, result.height *scale);
    
    //----------------HERE WE SETUP FOR IPHONE4/4s/iPod----------------------
    
            if(result.height == 960){
                storyBoard = [UIStoryboard storyboardWithName:@"iPhone4_Storyboard" bundle:nil];
                UIViewController *initViewController = [storyBoard instantiateInitialViewController];
                [self.window setRootViewController:initViewController];
            }
    
    //----------------HERE WE SETUP FOR IPHONE3/3s/iPod----------------------
    
            if(result.height == 480){
                storyBoard = [UIStoryboard storyboardWithName:@"iPhone4_Storyboard" bundle:nil];
                UIViewController *initViewController = [storyBoard instantiateInitialViewController];
                [self.window setRootViewController:initViewController];
            }
        }
    
            return YES;
     }
    

    So you have created a Universal app for iPhone 3/3Gs/4/4s/5 All gen of iPod, and All type of iPad

    Remember to integrate all IMG with myImage.png and myImage@2x.png

提交回复
热议问题