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

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

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


当前回答

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

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

其他回答

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

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

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

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

首先,创建两个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文件。

Peter,你真的应该看看Canappi,它为你做了所有这些,你所要做的就是指定这样的布局:

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

从那里Canappi将生成正确的objective-c代码,检测应用程序正在运行的设备,并将使用:

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

Canappi的工作原理类似于界面生成器和故事板的结合,除了它是文本形式。如果已经有XIB文件,可以转换它们,这样就不必从头重新创建整个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];
}

在这里你可以找到一个很好的教程(MonoTouch,但你也可以使用非MonoTouch项目的信息): http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/

为你的splash/default屏幕创建一个新图像(640 x 1136像素),名称为Default-568h@2x.png 在iOS模拟器中,转到硬件->设备菜单,并选择“iPhone(视网膜4英寸)” 创建其他图像,例如背景图像 检测iPhone 5加载你的新图像:


public static bool IsTall
{
    get {
        return UIDevice.currentDevice.userInterfaceIdiom
                    == UIUserInterfaceIdiomPhone
                && UIScreen.mainScreen.bounds.size.height
                    * UIScreen.mainScreen.scale >= 1136;
    }
}

private static string tallMagic = "-568h@2x";
public static UIImage FromBundle16x9(string path)
{
    //adopt the -568h@2x naming convention
    if(IsTall())
    {
        var imagePath = Path.GetDirectoryName(path.ToString());
        var imageFile = Path.GetFileNameWithoutExtension(path.ToString());
        var imageExt = Path.GetExtension(path.ToString());
        imageFile = imageFile + tallMagic + imageExt;
        return UIImage.FromFile(Path.Combine(imagePath,imageFile));
    }
    else
    {
        return UIImage.FromBundle(path.ToString());
    }
}