简体   繁体   English

迁移到iphone5无法正常工作?

[英]Migrating to iphone5 not working?

I have an application in iPhone 4, working fine. 我在iPhone 4中有一个应用程序,工作正常。 Now i want to migrate it to 5. I have a startupviewcontroller for displaying the splash image with a xib; 现在我想将它迁移到5.我有一个startupviewcontroller用于显示带有xib的splash图像; the xib is generated in Xcode 4.2 so it has a 320 480 framed view and an image view added to it with an image. xib是在Xcode 4.2中生成的,因此它有一个320 480的框架视图和一个带有图像的图像视图。 Now i want all this to be working in iPhone 5 also. 现在我希望所有这些都能在iPhone 5中运行。 For that i changed the image size to 640*1136 which is added to that image view than the used one of 640*960.And i added 为此,我将图像大小更改为640 * 1136,这是添加到该图像视图而不是使用的640 * 960.And我添加

if([[UIScreen mainScreen] bounds].size.height == 480)
    {
        [self.view setFrame:CGRectMake(0,0,320,480 )];
    }

    else 
    {
        [self.view setFrame:CGRectMake(0,0,320,568)];
        backgroundimage.image=[UIImage imageNamed:@"Default-568h@2x.png"];

        }

not working. 不工作 Which has giving me some blank space in the bottom after the image. 在图像之后,底部给了我一些空白区域。 I also tried autoresizing mask. 我也尝试过autoresizing mask。 That also didn't work. 这也行不通。

在此输入图像描述

Can anybody get me out of this dig? 任何人都可以让我脱离这个挖掘?

Looking at your code there are 2 things I would check: - make sure backgroundImage is hooked up properly to the nib. 查看代码,我会检查两件事: - 确保backgroundImage正确连接到nib。 - remove the @2x keyword to the image you are retrieving [UIImage imageNamed:@"Default-568h"]. - 删除要检索的图像的@ 2x关键字[UIImage imageNamed:@“Default-568h”]。 The @2x will be appended for you to get the right file. 将附加@ 2x以获取正确的文件。

Other than that what you have should work granted you have a valid launch 4 inch launch image (Default-568h@2x.png). 除此之外,你所拥有的工作应该是有效的,你有一个有效的启动4英寸发射图像(Default-568h@2x.png)。

I'm guessing that backgroundImage is a UIImageView which is a subview of your controller's view, set in the xib to be the full size of the view. 我猜测backgroundImage是一个UIImageView ,它是控制器视图的子视图,在xib中设置为视图的完整大小。 When your app runs on an iPhone 5, it will automatically set the size of the view for you, but it won't resize the subviews unless you set an autoresizing mask. 当您的应用在iPhone 5上运行时,它会自动为您设置视图的大小,但除非您设置自动调整大小,否则它不会调整子视图的大小。 See my answer to this question for how to do that. 请参阅我对此问题的答案,了解如何执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM