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

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

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


当前回答

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

其他回答

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

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.

首先显示这张图片。在那个图像中,你显示了视网膜4支持的警告,所以点击这个警告,然后点击添加,这样你的视网膜4启动屏幕自动添加到你的项目中。

在你使用这段代码之后

if([[UIScreen mainScreen] bounds].size.height == 568)
    {
        // For iphone 5
    }
    else
    {
        // For iphone 4 or less
    }

唯一真正需要做的事情是在应用程序资源中添加一个名为“Default-568h@2x.png”的启动图像,在一般情况下(如果你足够幸运)应用程序将正常工作。

如果应用程序不处理触摸事件,那么确保键窗口有适当的大小。解决方法是设置适当的框架:

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

在迁移到iOS 6时,还有其他与屏幕大小无关的问题。详情请阅读iOS 6.0发布说明。

如果你需要将一个已经存在的应用程序转换为通用,你需要选择相应的xib文件->show Utilities-> show Size inspector。

在大小检查器中,你可以看到自动调整大小,通过使用这个工具你可以转换到现有的iOS应用程序。