【问题标题】:How to show iPhone5-Splashscreen with PhoneGap V1.x如何使用 PhoneGap V1.x 显示 iPhone5-Splashscreen
【发布时间】:2012-11-09 19:06:45
【问题描述】:

有没有办法破解 PhoneGap 1.0 使其在 iPhone5 上显示正确的启动画面以避免 web 视图的白色闪烁?

我可以控制闪屏

if(navigator.splashscreen) navigator.splashscreen.hide();

但在 iPhone5 上显示错误的图像。我需要显示 Default-568h@2x.png 图像。 我知道在 PG2 中这是固定的,但我想避免更新整个项目。

【问题讨论】:

    标签: objective-c xcode cordova iphone-5


    【解决方案1】:

    我刚刚想出了如何在旧版 Phonegap 中解决这个问题,而且这是一个非常容易解决的问题。在 PhoneGapDelegate.m 中,找到这个:

    UIImage* image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]];
    imageView = [[UIImageView alloc] initWithImage:image];
    [image release];
    

    并替换为:

    UIImage* image;
    
    if ([[UIScreen mainScreen] bounds].size.height == 568.0f)
    {
        image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default-568h@2x" ofType:@"png"]];
    }
    else
    {
        image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]];
    }
    imageView = [[UIImageView alloc] initWithImage:image];
    [image release];
    

    由于某种原因,您需要为 iPhone 5 图像指定完整的图像名称,就像在上面的代码中一样。如果只使用@"Default-568h" 指定,则根本不会加载图像。

    【讨论】:

    • 找不到这个代码sn-p也找不到项目里面的文件。
    • 该文件应该在 PhoneGapLib/Classes 文件夹中。默认情况下,PhoneGapLib 位于您安装 PhoneGap 的任何位置。在 Mac 上,我认为那是 Documents 文件夹。您可以在 Spotlight 中搜索 PhoneGapLib,它会显示它的位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 2019-03-19
    • 2017-09-20
    • 2021-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多