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

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

    You can use the Auto Layout feature and create the design using iPhone 5 screen resolution and it will work for the both 4" and 3.5" devices, but in this case you should have a enough knowledge of layout manager.

    0 讨论(0)
  • 2020-11-21 06:03

    Point worth notice - in new Xcode you have to add this image file Default-568h@2x.png to assets

    0 讨论(0)
  • 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
    }
    
    0 讨论(0)
  • 2020-11-21 06:04

    The only really required thing to do is to add a launch image named "Default-568h@2x.png" to the app resources, and in general case (if you're lucky enough) the app will work correctly.

    In case the app does not handle touch events, then make sure that the key window has the proper size. The workaround is to set the proper frame:

    [window setFrame:[[UIScreen mainScreen] bounds]]
    

    There are other issues not related to screen size when migrating to iOS 6. Read iOS 6.0 Release Notes for details.

    0 讨论(0)
  • 2020-11-21 06:04

    Here you can find a nice tutorial (for MonoTouch, but you can use the information for Non-MonoTouch-projects, too):
    http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/

    1. Create a new image for your splash/default screen (640 x 1136 pixel) with the name "Default-568h@2x.png"

    2. In the iOS Simulator, go to the Hardware -> Device menu, and select "iPhone (Retina 4-inch)"

    3. Create other images, e.g. background images

    4. Detect iPhone 5 to load your new images:

    public static bool IsTall
    {
        get {
            return UIDevice.currentDevice.userInterfaceIdiom
                        == UIUserInterfaceIdiomPhone
                    && UIScreen.mainScreen.bounds.size.height
                        * UIScreen.mainScreen.scale >= 1136;
        }
    }
    

    private static string tallMagic = "-568h@2x";
    public static UIImage FromBundle16x9(string path)
    {
        //adopt the -568h@2x naming convention
        if(IsTall())
        {
            var imagePath = Path.GetDirectoryName(path.ToString());
            var imageFile = Path.GetFileNameWithoutExtension(path.ToString());
            var imageExt = Path.GetExtension(path.ToString());
            imageFile = imageFile + tallMagic + imageExt;
            return UIImage.FromFile(Path.Combine(imagePath,imageFile));
        }
        else
        {
            return UIImage.FromBundle(path.ToString());
        }
    }
    
    0 讨论(0)
  • 2020-11-21 06:04

    I solve this problem here. Just add ~568h@2x suffix to images and ~568h to xib's. No needs more runtime checks or code changes.

    0 讨论(0)
提交回复
热议问题