iOS 5.1和Default.png

我正在使用iOS 5.1开发应用程序,我遇到了default.png文件的一些奇怪行为.

我已将以下文件添加到我的应用程序中:

Default.png – (iPhone)

Default@2x.ping – (iPhone Retina)

Default-Portrait~ipad.png – (iPad)

Default-Portrait@2x~ipad.png -(iPad Retina)

当应用程序启动时,它似乎选择了正确的Default.png图像用于每个场合.但是在我的AppDelegate中,我有一个简单的启动画面,可以更轻松地加载应用程序并转换到应用程序,执行以下操作:

UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,window.frame.size.width,window.frame.size.height)]; 
splashView.image = [UIImage imageNamed:@"Default"]; 

[window addSubview:splashView]; 
[window bringSubviewToFront:splashView];

然而,[UIImage imageNamed:@“Default”]反过来没有为每个设备选择正确的文件,我相信问题是文件名的-Portrait部分.

所以作为一个快速解决方案,我这样做:

if( ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ) {
    // Force the image used by ipads
    if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) {
       splashView.image = [UIImage imageNamed:@"Default-Portrait@2x~ipad"];
    }
    else {
        splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad"];
    }
}
else
   splashView.image = [UIImage imageNamed:@"Default"];

这是我应该这样做的吗?这看起来对你有意思吗?

解决方法

有关官方信息,请查看: App-Related Resources

对于Launch图像,请使用以下格式:

<basename><orientation_modifier><scale_modifier><device_modifier>.png

它看起来你最好使用:

Default.png - (iPad)

Default@2x.png - (iPad Retina)

Default~iphone.png - (iPhone)

Default@2x~iphone.png -(iPhone Retina)

即使使用简单,这应该给你正确的图像:

splashView.image = [UIImage imageNamed:@"Default"];

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...