Phonegap - 无法以编程方式关闭iOS上的启动画面

时间:2014-12-18 07:28:53

标签: ios cordova splash-screen

我在iOS上有关于Phonegap的问题:无法以编程方式关闭启动画面 - 它只是保持可见。

当我更改启动画面配置以启用自动隐藏时,它会隐藏而不会出现问题。

另请注意,在Android上它运行正常。

这是我的配置:

<preference name="detect-data-types" value="true"/>
<preference name="exit-on-suspend" value="false"/>
<preference name="show-splash-screen-spinner" value="true"/>
<preference name="android-minSdkVersion" value="14"/>
<preference name="android-installLocation" value="auto"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="SplashScreen" value="screen"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="auto-hide-splash-screen" value="false" />
<preference name="SplashScreenDelay" value="100000" />
<preference name="StatusBarOverlaysWebView" value="false" />

 <feature name="SplashScreen">
    <param name="ios-package" value="CDVSplashScreen"/>
    <param name="onload" value="true" />
 </feature>

Javascript(我正在使用Angular + Ionic框架)

.$ionicPlatform.ready(function () {

   setTimeout(function(){
      navigator.splashscreen.hide();
   }, 1000);
 })

3 个答案:

答案 0 :(得分:1)

I know this is an older question, but in case somebody else needs help. It might be fine on Android because everything (including navigator.splashscreen) loaded before the deviceready was called. What I had to do was remove the ng-app attribute and add an event listener for deviceready on the index page which then starts the angular application when everything is available.

<script type="text/javascript">
  document.addEventListener('deviceready', function onDeviceReady() {
   angular.bootstrap(document, ['myApp']);
  }, false);
 </script>

I found information on this at:

how to deviceready in right way in ionic application

Ionic Framework Forum

答案 1 :(得分:0)

该线路是否有错误?如果您没有为您的应用程序使用远程调试程序,则可以在发生异常时通过警报进行检查。例如:

try {
    navigator.splashscreen.hide();
}
catch (e) {
    alert(e); // This might be object, though, so maybe not showing the cause
}

如果出现错误,可能意味着您没有为您的应用程序正确安装SplashScreen插件。您可以在此处查看described

答案 2 :(得分:0)

您可以尝试以下

$ionicPlatform.ready(
function(){
    $cordovaSplashscreen.hide();
});

注意:您需要调用$cordivaSplashscreen.hide()函数。如果您使用的是IONIC Framework,则可能需要使用NG Cordova Plugins

同样,如果您想使用超时,可以使用以下代码

$ionicPlatform.ready(function() {
     var hidesplashscreen = function() {
                $cordovaSplashscreen.hide();
     };
     $timeout(hidesplashscreen, 2000);
});