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

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

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


当前回答

我想,它不是在所有情况下都能工作,但在我的特定项目中,它避免了我对nib文件的重复:

在common.h中,你可以根据屏幕高度来做这些定义:

#define HEIGHT_IPHONE_5 568
#define IS_IPHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5)

在你的基本控制器中:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (IS_IPHONE_5) {
        CGRect r = self.view.frame;
        r.size.height = HEIGHT_IPHONE_5 - 20;
        self.view.frame = r;
    }
    // now the view is stretched properly and not pushed to the bottom
    // it is pushed to the top instead...

    // other code goes here...
}

其他回答

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

我添加了新的默认启动图像,(在检查其他几个SE答案…)确保我的故事板都自动大小和子视图,但视网膜4英寸仍然是信箱。

然后我注意到我的信息plist有一个行项目“启动图像”设置为“Default.png”,因此我删除了它,神奇的字母盒不再出现。希望这能让别人免受我所经历的疯狂。

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

首先,创建两个xib并将所有委托,main类附加到xib,然后你可以在你的appdelegate中放入下面提到的条件。M文件在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

    if ([[UIScreen mainScreen] bounds].size.height == 568)
        {

        self.ViewController = [[ViewController alloc] initWithNibName:@"ViewControlleriphone5" bundle:nil];
        }

        else
        {
             self.ViewController = [[ViewController alloc] initWithNibName:@"ViewControlleriphone4" bundle:nil];

        }

你可以在程序的任何地方使用它,这取决于你的需求,甚至在你的ViewController类中。最重要的是,您已经为iphone 4(320*480)和iphone 5(320*568)分别创建了两个xib文件。

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.