iOS 5.1 和 Default.png

标签 ios ipad ios5

我正在使用 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,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 5.1 和 Default.png,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10122750/

相关文章:

ios - 不使用 Xcode 制作 Cocoa 应用程序,例如 : using VIM for editing and the Swift compiler

iphone - 如何在iPhone App中实现PSCollectionView?

ios - iPhone 模拟器立即崩溃并显示 EXC_BAD_ACCESS

ios - iOS 9.3 上 iPad 上的 PHCachingImageManager 问题

c++ - 链接器命令失败,退出代码为 1 - Xcode

ios - 如何从 OSX 终端将文件推送到未越狱的 iPad/iPhone?

javascript - 在 MobileSafari 上使用 Javascript 管理大量图像

iphone - iOS:覆盖 NSLocale 语言

ios - 在 Swift 中设置 NSManagedObject 关系

css - 禁用 xscroll ipad