飞溅后的Phonegap 3白色闪光灯

时间:2013-08-02 00:15:46

标签: ios cordova

我知道这已被多次询问(和回答)(Phonegap showing white screen after the splash screen - IOSPhonegap 2.0 - on app launch a white screen flashes prior to my app loadinghow to to kill the white flickering splashscreen at the start of phonegap iOS app?)但这些解决方案似乎都不适合我。也许是因为我使用的是Phonegap第3版?

我只加载Phonegap和jQuery 2.0.0(其他解决方案处理我不使用的jQuery-mobile),我只是针对iOS进行部署。我有一个启动图像加载,然后应用程序显示一个白色的屏幕(持续时间不同 - 我猜它正在加载应用程序?)然后我的index.html加载我的第一个屏幕。这是我目前的负责人:

<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

    <link type="text/css" rel="stylesheet" href="css/main.css" />

    <title>My App</title>

    <script type="text/javascript" src="phonegap.js"></script>
    <script src="js/lib/jquery-2.0.0.min.js"></script>
    <script src="js/main.js"></script>      
</head>

我尝试将此添加到我的config.xml(与index.html在同一文件夹级别):

<preference name="backgroundColor" value="0x000000" />

但我仍然得到白屏闪光。我还尝试手动隐藏/显示启动:

function onDeviceReady() {
    navigator.splashscreen.show();
}

但这似乎没有任何影响。有人有什么建议吗?

5 个答案:

答案 0 :(得分:18)

我终于能够消除飞溅闪光,但我不得不使用Cordova来做到这一点。以下是我采取的步骤:

在终点站:

cordova create ~/path/to/project “com.appname.app” “appName”
cd ~/path/to/project
cordova platform add ios
cordova build
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git
cordova build

使用Finder导航至~/path/to/project/platforms/ios/,然后双击projectname.xcodeproj以在Xcode中打开项目。

接下来,我进去编辑了图像。你可以通过多种方式做到这一点。这就是我所做的:在Xcode中,导航到Resources/splash/,右键单击要更改的图像,选择Show in Finder并使用您想要更改图像的任何工具。

完成后,返回Xcode并打开根级config.xml(仍然不确定为什么有两个config.xml文件,但你想要文件夹结构中最远的文件。将AutoHideSplashScreen属性更新为

<preference name="AutoHideSplashScreen" value="false" />

在Xcode主菜单中,选择Product > Clean,然后选择Product > Build

反复为我工作。然后,我可以使用我的应用中的navigator.splashscreen.show()navigator.splashscreen.hide()方法(如果不执行所有这些步骤,它们似乎没有响应)。

希望这有帮助!

答案 1 :(得分:4)

我遇到插件问题或者手机盖有问题

function onDeviceReady() {
    navigator.splashscreen.show();
}

对我不起作用。

我通过将webview alpha设置为0来修复它,直到它被加载:

3个步骤:

    方法“"CDVViewController.m"”中文件-(void)createGapView中的
  1. 我添加了:
    self.webView.alpha = 0;
  2. 方法“"MainViewController.m"中的文件-(void)WebViewDidFinishLoad:(UIWebView*)theWebView"中的
  3. 我添加了:theVebView.alpha=1;
  4. 文件"MainController.xib"中的
  5. 我将背景更改为黑色(将其设置为您喜欢的任何颜色)。
  6. 现在,在内容完全加载之前,我将使用黑色屏幕而不是白屏闪光灯。 对我来说足够好。 (虽然不完美)

    希望这会有所帮助..

答案 2 :(得分:1)

尝试添加

<param name="onload" value="true" />到config.xml中的SplashScreen功能。

答案 3 :(得分:0)

这对我使用build.phonegap.com

步骤1:将Slashscreen插件添加到config.xml

<gap:plugin name="org.apache.cordova.splashscreen" version="0.2.7" />

步骤2:使用此首选项更新config.xml。

<preference name="auto-hide-splash-screen" value="false" />

第3步:在您的设备已添加插件功能调用&#39;事件

<script>
  document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() {
   navigator.splashscreen.hide()
  }
</script>

答案 4 :(得分:0)

在使用splash插件后,我发现了这个解决方案:

  1. 在MainViewController.xib中,添加一个UIImageView(imgView)。
  2. 将你的飞溅图像放入其中,设置比例填充。
  3. 在MainViewController.m中,覆盖 - (void)webViewDidFinishLoad:(UIWebView *)theWebView
  4. 在[super webViewDidFinishLoad:theWebView]之后添加这些代码;

    [self.view sendSubviewToBack:imgView];

    imgView.hidden = YES;