0

有没有办法破解 PhoneGap 1.0 使其在 iPhone5 上显示正确的闪屏以避免 webview 的白色闪烁?

我可以控制启动画面

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

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

4

1 回答 1

1

I have just figured out how to fix this issue in older Phonegap, and it's a pretty easy fix. In PhoneGapDelegate.m, find this:

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

and replace with this:

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];

For some reason, you need to specify full image name for iPhone 5 image just like in the code above. If you specify it with just @"Default-568h", image won't be loaded at all.

于 2012-12-04T01:30:19.253 回答