splashscreen不隐藏

时间:2016-10-06 10:46:03

标签: android ionic2 splash-screen

我输入app.ts:

import { Splashscreen } from 'ionic-native';

在构造函数中:

platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      this.hideSplashScreen()
 }

功能:

hideSplashScreen() {
    if(navigator && navigator.splashscreen) {
    setTimeout(()=> {
       navigator.splashscreen.hide();
    }, 100);
}
in config.xml:
<preference name="ShowSplashScreen" value="true"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="30000"/>
  <preference name="AutoHideSplashScreen" value="false"/>
  <preference name="SplashShowOnlyFirstTime" value="false"/>
  <preference name="FadeSplashScreen" value="false"/>
  <feature name="SplashScreen">
      <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
  </feature>

在打字中,我的pluginshackyhacky.d.ts是:

interface /*PhoneGapNavigator extends*/ Navigator {
  app: any;
  splashscreen: Splashscreen;
}

在设备和模拟器中,Slash屏幕根本不隐藏......

一旦我把“splashscreen:Splashscreen;”在pluginshackyhacky.d.ts文件中,Ionic在控制台中输出404错误: http://localhost:8100/build/js/app.bundle.js无法加载资源:服务器响应状态为404(未找到)

我的错误或RC0无法与slpashscreen一起使用?

彼得

1 个答案:

答案 0 :(得分:0)

版本离子版2.3.0更新

要隐藏启动画面,请从离子本机导入启动画面并创建对象以使用方法

import { SplashScreen } from '@ionic-native/splash-screen';
export class your_class{
public splashScreen: SplashScreen;
 constructor(platform: Platform) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.splashScreen.hide();
    });
  }
}

版本2.0

在构造函数中使用以下代码

platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
 }

离子原生Splashscreen拥有处理闪屏的所有方法。不需要打字