I'm updating my PhoneGap iOS-app to make it compatible with the iPhone 5.
我正在更新我的PhoneGap iOS应用程序,使其与iPhone 5兼容。
I'm manually hiding the splash screen after my app has initialized.
我的应用初始化后,我手动隐藏了启动画面。
When simulating iPhone 5: When the app starts it displays the correct splash screen (Default-568h@2x.png) (hereon "the 5") but quickly hides it and instead displays the iPhone 4 splash screen (hereon "the 4"). The 4 doesn't cover the whole app, thus showing top and bottom bars of the app initializing.
模拟iPhone 5时:当应用程序启动时,它会显示正确的启动画面(Default-568h@2x.png)(此处为“5”)但会快速隐藏它,而是显示iPhone 4启动画面(此处为“4”) 。 4不包括整个应用程序,因此显示应用程序初始化的顶部和底部栏。
I'm not entirely sure how it works but I can think of two possible scenarios: 1) Both images are displayed simultaneously but for some reason the 5 auto hides while the 4 waits for the call from the app to hide. 2) At some point when disabling manually hiding the splash screen phonegap switches out the "true" splashscreen for a "fake" one that is displayed until the javascript call from the app and phonegap just might not display correct one after this switcheroo.
我不完全确定它是如何工作的但我可以想到两种可能的情况:1)两个图像同时显示但由于某种原因5个自动隐藏,而4等待来自应用程序的呼叫隐藏。 2)在某些时候禁用手动隐藏启动画面时,phonegap会切换出“真实”的启动画面,直到来自应用程序和手机屏幕的javascript调用可能无法在此切换器后显示正确的“假”。
Has anyone else encountered and / or solved this?
还有其他人遇到和/或解决了这个问题吗?
UPDATE: Tried removing and adding all splash images again but to no avail. I tried removing the smaller images (the 4 and its non-retina version) but even without the smaller ones present anywhere in the project I get the same error!
更新:尝试再次删除并添加所有启动图像,但无济于事。我尝试删除较小的图像(4和它的非视网膜版本),但即使没有项目中任何地方的较小的图像我得到相同的错误!
UPDATE 2: Cordova 2.2.0 has now been released, thus fixing this issue according to: http://shazronatadobe.wordpress.com/2012/10/27/whats-new-in-cordova-ios-2-2-0/
更新2:Cordova 2.2.0现已发布,因此根据以下内容修复此问题:http://shazronatadobe.wordpress.com/2012/10/27/whats-new-in-cordova-ios-2-2-0 /
So, the recommended solution would therefore be to update your app to use Cordova 2.2.0, if that is for some reason not possible, solutions are provided below.
因此,建议的解决方案是更新您的应用程序以使用Cordova 2.2.0,如果由于某种原因不可能,则提供以下解决方案。
3 个解决方案
#1
19
I've received two answers elsewhere but haven't had time to test them out yet: From user T123 in the Phonegap Google Group: open CDVViewController.m -- find - (void) showSplashScreen
我在其他地方收到了两个答案,但还没来得及测试它们:来自Phonegap Google Group的用户T123:打开CDVViewController.m - 找 - (void)showSplashScreen
change about line: 690
换线:690
From :
来自:
else // not iPad
{
orientedLaunchImageFile = launchImageFile;
}
To:
至:
else // not iPad
{
orientedLaunchImageFile = launchImageFile;
/* Edited for 4-inch IP5 */
if(screenBounds.size.height == 568)
orientedLaunchImageFile = [NSString stringWithFormat:@"%@-568h", launchImageFile];
}
And from Brion who commented above, the following pull request, hoepfully to be incorporated into Cordova 2.2.0: https://github.com/apache/incubator-cordova-ios/pull/50
从上面评论过的Brion,以下拉动请求,可以并入Cordova 2.2.0:https://github.com/apache/incubator-cordova-ios/pull/50
EDIT: Tried T123's solution and it's working for me! EDIT2: Brion's fix was incorporated in Cordova 2.2.0 which has now been released!
编辑:试过T123的解决方案,它对我有用!编辑2:Brion的修复程序已合并到Cordova 2.2.0中,现已发布!
EDIT3: Just updating to highlight a comment for those who don't bother reading them:
编辑3:只是更新以突出显示那些不打扰阅读它们的人的评论:
For Phonegap version 1.4.1, I managed to get Hessius's fix to work like this: I copied the methods showSplashScreen, isIPad, resolveImageResource and the definition #define degreesToRadian(x) (M_PI * (x) / 180.0) from the file PGViewController.m to my MainViewController.m file. After that, XCode complained that I was assigning values to read-only attributes, so I edited the header file in PhoneGap.framework to make those two attributes readwrite. I also changed launchImageFilefrom Hessius's code to @"Default". This did the trick for me. – Joe Dyndale Oct 8 '12 at 15:23
对于Phonegap版本1.4.1,我设法让Hessius的修复工作如下:我从文件PGViewController复制了方法showSplashScreen,isIPad,resolveImageResource和定义#define degreesToRadian(x)(M_PI *(x)/ 180.0)。 m到我的MainViewController.m文件。之后,XCode抱怨我正在为只读属性赋值,所以我在PhoneGap.framework中编辑了头文件,使这两个属性读写。我还将launchImageFile从Hessius的代码更改为@“Default”。这对我有用。 - Joe Dyndale 12年8月8日15:23
#2
1
The fix for this (https://issues.apache.org/jira/browse/CB-1482) is not out until 2.2. It is very risky to use the unstable version and I don't bother to compile from source code myself, so I tried the following hack:
对此的修复(https://issues.apache.org/jira/browse/CB-1482)直到2.2才会出现。使用不稳定版本是非常危险的,我不打算自己编译源代码,所以我尝试了以下hack:
In MainViewController.m
在MainViewController.m中
- (void) showSplashScreen
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
// HACK: PhoneGap pre-2.2 does not support iphone5 splash image well, so we just skip it
if (screenBounds.size.height == 568) {
return;
}
[super showSplashScreen];
}
This will disable showSplashScreen for iPhone5 to avoid the shorter launch image added by PhoneGap (iOS initial launch image is showing up fine). It worked for me and I barely notice any difference by hacking off showSplashScreen for iPhone5.
这将禁用iPhone5的showSplashScreen,以避免PhoneGap添加较短的启动图像(iOS初始启动图像显示正常)。它适用于我,我几乎没有注意到通过破解showSplashScreen for iPhone5的任何差异。
#3
0
White Flicker
白色闪烁
I was having this same problem with Cordova 2.2. I think it is worth mentioning that I had to take an added step in order to get the splash screen to render correctly.
我在Cordova 2.2上遇到了同样的问题。我认为值得一提的是,我必须采取额外的步骤才能使启动画面正确渲染。
I made the changes that were included in @Hessius answer. But I noticed that a white screen flash was produced after the splash screen appeared.
我做了@Hessius回答中包含的更改。但我注意到在闪屏出现后产生了白屏闪光。
In the (void)showSplashScreen method others may see
在(void)showSplashScreen方法中,其他人可能会看到
if (launchImageFile == nil) { // fallback if no launch image was specified
// if (CDV_IsIPhone5()) {
// // iPhone 5 or iPod Touch 6th-gen
// launchImageFile = @"Default-568h";
// } else {
launchImageFile = @"Default";
// }
}
Commenting the code out(or removing) that I have commented, eliminated the white flicker I was seeing in between app load and launch screen.
评论我所评论的代码(或删除),消除了我在应用程序加载和启动屏幕之间看到的白色闪烁。
Hope this helps someone!
希望这有助于某人!
#1
19
I've received two answers elsewhere but haven't had time to test them out yet: From user T123 in the Phonegap Google Group: open CDVViewController.m -- find - (void) showSplashScreen
我在其他地方收到了两个答案,但还没来得及测试它们:来自Phonegap Google Group的用户T123:打开CDVViewController.m - 找 - (void)showSplashScreen
change about line: 690
换线:690
From :
来自:
else // not iPad
{
orientedLaunchImageFile = launchImageFile;
}
To:
至:
else // not iPad
{
orientedLaunchImageFile = launchImageFile;
/* Edited for 4-inch IP5 */
if(screenBounds.size.height == 568)
orientedLaunchImageFile = [NSString stringWithFormat:@"%@-568h", launchImageFile];
}
And from Brion who commented above, the following pull request, hoepfully to be incorporated into Cordova 2.2.0: https://github.com/apache/incubator-cordova-ios/pull/50
从上面评论过的Brion,以下拉动请求,可以并入Cordova 2.2.0:https://github.com/apache/incubator-cordova-ios/pull/50
EDIT: Tried T123's solution and it's working for me! EDIT2: Brion's fix was incorporated in Cordova 2.2.0 which has now been released!
编辑:试过T123的解决方案,它对我有用!编辑2:Brion的修复程序已合并到Cordova 2.2.0中,现已发布!
EDIT3: Just updating to highlight a comment for those who don't bother reading them:
编辑3:只是更新以突出显示那些不打扰阅读它们的人的评论:
For Phonegap version 1.4.1, I managed to get Hessius's fix to work like this: I copied the methods showSplashScreen, isIPad, resolveImageResource and the definition #define degreesToRadian(x) (M_PI * (x) / 180.0) from the file PGViewController.m to my MainViewController.m file. After that, XCode complained that I was assigning values to read-only attributes, so I edited the header file in PhoneGap.framework to make those two attributes readwrite. I also changed launchImageFilefrom Hessius's code to @"Default". This did the trick for me. – Joe Dyndale Oct 8 '12 at 15:23
对于Phonegap版本1.4.1,我设法让Hessius的修复工作如下:我从文件PGViewController复制了方法showSplashScreen,isIPad,resolveImageResource和定义#define degreesToRadian(x)(M_PI *(x)/ 180.0)。 m到我的MainViewController.m文件。之后,XCode抱怨我正在为只读属性赋值,所以我在PhoneGap.framework中编辑了头文件,使这两个属性读写。我还将launchImageFile从Hessius的代码更改为@“Default”。这对我有用。 - Joe Dyndale 12年8月8日15:23
#2
1
The fix for this (https://issues.apache.org/jira/browse/CB-1482) is not out until 2.2. It is very risky to use the unstable version and I don't bother to compile from source code myself, so I tried the following hack:
对此的修复(https://issues.apache.org/jira/browse/CB-1482)直到2.2才会出现。使用不稳定版本是非常危险的,我不打算自己编译源代码,所以我尝试了以下hack:
In MainViewController.m
在MainViewController.m中
- (void) showSplashScreen
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
// HACK: PhoneGap pre-2.2 does not support iphone5 splash image well, so we just skip it
if (screenBounds.size.height == 568) {
return;
}
[super showSplashScreen];
}
This will disable showSplashScreen for iPhone5 to avoid the shorter launch image added by PhoneGap (iOS initial launch image is showing up fine). It worked for me and I barely notice any difference by hacking off showSplashScreen for iPhone5.
这将禁用iPhone5的showSplashScreen,以避免PhoneGap添加较短的启动图像(iOS初始启动图像显示正常)。它适用于我,我几乎没有注意到通过破解showSplashScreen for iPhone5的任何差异。
#3
0
White Flicker
白色闪烁
I was having this same problem with Cordova 2.2. I think it is worth mentioning that I had to take an added step in order to get the splash screen to render correctly.
我在Cordova 2.2上遇到了同样的问题。我认为值得一提的是,我必须采取额外的步骤才能使启动画面正确渲染。
I made the changes that were included in @Hessius answer. But I noticed that a white screen flash was produced after the splash screen appeared.
我做了@Hessius回答中包含的更改。但我注意到在闪屏出现后产生了白屏闪光。
In the (void)showSplashScreen method others may see
在(void)showSplashScreen方法中,其他人可能会看到
if (launchImageFile == nil) { // fallback if no launch image was specified
// if (CDV_IsIPhone5()) {
// // iPhone 5 or iPod Touch 6th-gen
// launchImageFile = @"Default-568h";
// } else {
launchImageFile = @"Default";
// }
}
Commenting the code out(or removing) that I have commented, eliminated the white flicker I was seeing in between app load and launch screen.
评论我所评论的代码(或删除),消除了我在应用程序加载和启动屏幕之间看到的白色闪烁。
Hope this helps someone!
希望这有助于某人!