新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。

开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?

我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?


当前回答

使用xCode 5,在项目>General上选择“迁移到资产目录”。

然后使用“Show in finder”找到你的启动图像,你可以模拟编辑它为640x1136,然后拖到资产目录,如下图所示。

确保iOS7和iOS6 R4部分都有一个640x1136的图像。下次你启动应用程序时,黑条将消失,你的应用程序将使用4英寸的屏幕

其他回答

这是一个真正的通用代码,你可以创建3个不同的故事板:

设置你的项目通用模式,用iPhone5 storyboard设置你的主故事iPhone,用ipad target storyboard设置ipad main,现在为iPhone添加新的storyboard target,并修改iPhone 4s或更少的分辨率,现在实现你的appdelegate。m

iPhone4/4s (3/ 3g是一样的)一个iPhone5,并使项目通用,与一个新的Storyboard目标为iPad,现在在AppDelegate。在didFinishLaunching下添加以下代码:

    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;
 }

所以你已经为iPhone 3/ 3g /4/4s/5所有一代的iPod和所有类型的iPad创建了一个通用应用程序

记住将所有IMG与myImage.png和myImage@2x.png集成

Download and install latest version of Xcode. Set a Launch Screen File for your app (in the general tab of your target settings). This is how you get to use the full size of any screen, including iPad split view sizes in iOS 9. Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly, or used Auto Layout. If you didn't, adjust your view layouts, preferably with Auto Layout. If there is something you have to do for the larger screens specifically, then it looks like you have to check height of [[UIScreen mainScreen] bounds] as there seems to be no specific API for that. As of iOS 8 there are also size classes that abstract screen sizes into regular or compact vertically and horizontally and are recommended way to adapt your UI.

I never faced such an issue with any device as I've had one codebase for all, without any hardcoded values. What I do is to have the maximum sized image as resource instead of one for each device. For example, I would have one for retina display and show it as aspect fit so it will be views as is on every device. Coming to deciding the frame of button, for instance, at run time. For this I use the % value of the patent view, example , if I want the width to be half of parent view take 50 % of parent and same applies for height and center.

有了这个,我甚至不需要xib。

我解决了这个问题。只需要在图像中添加~568h@2x后缀,在xib的图像中添加~568h。不需要更多的运行时检查或代码更改。

According to me the best way of dealing with such problems and avoiding couple of condition required for checking the the height of device, is using the relative frame for views or any UI element which you are adding to you view for example: if you are adding some UI element which you want should at the bottom of view or just above tab bar then you should take the y origin with respect to your view's height or with respect to tab bar (if present) and we have auto resizing property as well. I hope this will work for you