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

后端 未结 30 3219
醉话见心
醉话见心 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:03

    There is a slight problem when testing on both iOS device and iOS Simulator. It appears that simulator (XCode 6.0.1) gives switched values for width and height in [[UIScreen mainScreen] bounds].size depending on a device orientation.

    So this might be a problem when determinating the right physical screen size. This code helps also to distinct all 2014. iPhone model generations:

    • iPhone4s
    • iPhone5 (and iPhone5s)
    • iPhone6 (and iPhone6+)

    It can also be easily changed to make the distinction between e.g. iPhone6 from iPhone6+.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
    
        if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
        {
            if (iOSDeviceScreenSize.width > 568 || // for iOS devices
                iOSDeviceScreenSize.height > 568) // for iOS simulator
            {   // iPhone 6 and iPhone 6+
    
                // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone6
                storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone6" bundle:nil];
    
                NSLog(@"loaded iPhone6 Storyboard");
            }
            else if (iOSDeviceScreenSize.width == 568 || // for iOS devices
                     iOSDeviceScreenSize.height == 568) // for iOS simulator
            {   // iPhone 5 and iPod Touch 5th generation: 4 inch screen (diagonally measured)
    
                // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone5
                storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5" bundle:nil];
    
                NSLog(@"loaded iPhone5 Storyboard");
            }
            else
            {   // iPhone 3GS, 4, and 4S and iPod Touch 3rd and 4th generation: 3.5 inch screen (diagonally measured)
    
                    // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
                storyboard = [UIStoryboard story    boardWithName:@"MainStoryboard_iPhone" bundle:nil];
    
                    NSLog(@"loaded iPhone4 Storyboard");
            }
        }
        else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
        {   // The iOS device = iPad
    
            storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPadnew" bundle:nil];
    
            NSLog(@"loaded iPad Storyboard");
        }
    
        // rest my code
    }
    

提交回复
热议问题