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

后端 未结 30 3220
醉话见心
醉话见心 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 05:54

    First show this image. In that image you show warning for Retina 4 support so click on this warning and click on add so your Retina 4 splash screen automatically add in your project.

    Show image here

    and after you use this code :

    if([[UIScreen mainScreen] bounds].size.height == 568)
        {
            // For iphone 5
        }
        else
        {
            // For iphone 4 or less
        }
    
    0 讨论(0)
  • 2020-11-21 05:54

    Peter, you should really take a look at Canappi, it does all that for you, all you have to do is specify the layout as such:

    button mySubmitButton 'Sumbit' (100,100,100,30 + 0,88,0,0) { ... }
    

    From there Canappi will generate the correct objective-c code that detects the device the app is running on and will use:

    (100,100,100,30) for iPhone4
    (100,**188**,100,30) for iPhone 5
    

    Canappi works like Interface Builder and Story Board combined, except that it is in a textual form. If you already have XIB files, you can convert them so you don't have to recreate the entire UI from scratch.

    0 讨论(0)
  • 2020-11-21 05:54

    You could add this code:

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
            if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
                CGSize result = [[UIScreen mainScreen] bounds].size;
                CGFloat scale = [UIScreen mainScreen].scale;
                result = CGSizeMake(result.width * scale, result.height * scale);
    
                if(result.height == 960) {
                    NSLog(@"iPhone 4 Resolution");
                }
                if(result.height == 1136) {
                  NSLog(@"iPhone 5 Resolution");
                }
            }
            else{
                NSLog(@"Standard Resolution");
            }
        }
    
    0 讨论(0)
  • 2020-11-21 05:54

    If you need to convert an already existing app to universal, you need to select corresponding xib file->show Utilities-> Show Size inspector.

    In Size inspector you can see Autosizing, by using this tool you can convert to existing iOS App.

    0 讨论(0)
  • 2020-11-21 05:55

    It's easy for migrating iPhone5 and iPhone4 through XIBs.........

    UIViewController *viewController3;
    if ([[UIScreen mainScreen] bounds].size.height == 568)
    {
        UIViewController *viewController3 = [[[mainscreenview alloc] initWithNibName:@"iphone5screen" bundle:nil] autorelease];               
    }    
    else
    {
         UIViewController *viewController3 = [[[mainscreenview alloc] initWithNibName:@"iphone4screen" bundle:nil] autorelease];
    }
    
    0 讨论(0)
  • 2020-11-21 05:56

    Using xCode 5, select "Migrate to Asset Catalog" on Project>General.

    Then use "Show in finder" to find your launch image, you can dummy-edit it to be 640x1136, then drag it into the asset catalog as shown in the image below.

    Make sure that both iOS7 and iOS6 R4 section has an image that is 640x1136. Next time you launch the app, the black bars will disappear, and your app will use 4 inch screen

    enter image description here

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