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

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

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


当前回答

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。

其他回答

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。

如果你的应用是为iPhone 4S或更早版本开发的,那么它将在iPhone 5上运行letterbox。

为了使你的应用程序适应新的更高的屏幕,你要做的第一件事是将启动图像更改为:Default-568h@2x.png。其大小应为1136x640 (HxW)。是的,在新的屏幕大小中设置默认图像是让你的应用占据整个新iPhone 5屏幕的关键。

(注意,命名约定只适用于默认映像。将另一个图像命名为“Image-568h@2x.png”不会导致它取代“Image@2x.png”被加载。如果你需要为不同的屏幕大小加载不同的图像,你必须通过编程来实现。)

如果你非常非常幸运,可能就是这样……但十有八九,你还得多走几步。

确保你的xib / view使用自动布局来调整自己的大小。 使用spring和struts来调整视图的大小。 如果这对你的应用不够好,设计你的xib/storyboard 的特定屏幕尺寸和以编程方式重新定位 其他。

在极端情况下(当以上都不满足时),设计两个xib并在视图控制器中加载适当的一个。

检测屏幕大小:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        // iPhone Classic
    }
    if(result.height == 568)
    {
        // iPhone 5
    }
}

我建议在你的应用程序中根据你的UI界面使用自动调整蒙版,这节省了很多麻烦,比为iPhone 4和5屏幕制作不同的UI更好。

通过xib .........很容易迁移iPhone5和iPhone4

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

值得注意的是,在新的Xcode中,你必须将这个图像文件Default-568h@2x.png添加到资产中