Cordova - 如何去除启动画面?

4

我不想在我的Cordova项目(Android和iOS)中使用启动画面,如何去除它?我尝试禁用启动画面插件,但它仍然出现!该怎么解决?

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" id="app.appname" version="1.0.0">
    <name>App name</name>
    <description>
        App name description
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html"/>
    <plugin name="cordova-plugin-whitelist" spec="1"/>
    <access origin="*"/>
    <allow-intent href="http://*/*"/>
    <allow-intent href="https://*/*"/>
    <allow-intent href="tel:*"/>
    <allow-intent href="sms:*"/>
    <allow-intent href="mailto:*"/>
    <allow-intent href="geo:*"/>
    <platform name="android">
        <allow-intent href="market:*"/>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*"/>
        <allow-intent href="itms-apps:*"/>
    </platform>
    <preference name="SplashScreen" value="none"/>
</widget>

1
在iOS中,当用户请求启动应用程序并且应用程序加载并准备好运行时,会出现一个启动屏幕。这不是“闪屏”,一些应用程序在启动屏幕之后还有一个闪屏,这是被苹果公司所不鼓励的。 - zaph
你可以直接尝试从Android和iOS的源代码中删除/修改。 - Sanif SS
@SanifSS 我不相信对于如此简单和微不足道的事情,我必须这样做... - Joy
你使用的是哪个 Cordova 版本?我正在使用 CLI V 5.4.1 中的 Cordova,但默认创建的应用程序没有启动画面。 - Hisham
你能否编辑帖子并附上你的config.xml文件? - Hisham
显示剩余4条评论
4个回答

2

如果您在项目中使用cordova,您可以通过将以下标签添加到config.xml中轻松地移除启动画面

<preference name="SplashScreen" value="none"/>

2

请按照以下方式在config.xml中进行更改:

<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="0"/>

这个对你有用吗,Joy?我也遇到了同样的问题,但是这两个设置没有任何区别。 - Leif John

1
如果选项:
<preference name="SplashScreen" value="none"/>

不起作用。

您可以在onDeviceReady中添加此函数来完成操作:

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

在您的config.xml文件中必须包含splashscreen插件。
<gap:plugin name="org.apache.cordova.splashscreen" />

如果这个选项不起作用,您可以将启动画面默认图片放在空白处,并放入您的config.xml中。
<gap:splash src="splash.png" /

将splash.png图片放在您项目的根目录下。

1
啊,终于!我也曾为同样的问题苦恼。至少在IOS版本中,似乎无论我尝试什么,启动画面都是必须的。
我发现我可以为每个支持/推荐的大小添加png文件,然后启动时就会使用其中一个。我选择了一张适当的图片,但如果你想要的话,你也可以创建一个空白(白色或黑色)的png。
Phonegap或IOS非常挑剔,需要提供所有各种大小的图片,请确保它们都具备。
<platform name="ios">
    <icon platform="ios" src="www/res/icon/ios/icon.png"          height="57"  width="57" />
    <icon platform="ios" src="www/res/icon/ios/icon@2x.png"       height="114" width="114" />
    <icon platform="ios" src="www/res/icon/ios/icon-40.png"       height="40"  width="40" />
    <icon platform="ios" src="www/res/icon/ios/icon-40@2x.png"    height="80"  width="80" />
    <icon platform="ios" src="www/res/icon/ios/icon-50.png"       height="50"  width="50" />
    <icon platform="ios" src="www/res/icon/ios/icon-50@2x.png"    height="100" width="100" />
    <icon platform="ios" src="www/res/icon/ios/icon-60.png"       height="60"  width="60" />
    <icon platform="ios" src="www/res/icon/ios/icon-60@2x.png"    height="120" width="120" />
    <icon platform="ios" src="www/res/icon/ios/icon-60@3x.png"    height="180" width="180" />
    <icon platform="ios" src="www/res/icon/ios/icon-72.png"       height="72"  width="72" />
    <icon platform="ios" src="www/res/icon/ios/icon-72@2x.png"    height="144" width="144" />
    <icon platform="ios" src="www/res/icon/ios/icon-76.png"       height="76"  width="76" />
    <icon platform="ios" src="www/res/icon/ios/icon-76@2x.png"    height="152" width="152" />
    <icon platform="ios" src="www/res/icon/ios/icon-small.png"    height="29"  width="29" />
    <icon platform="ios" src="www/res/icon/ios/icon-small@2x.png" height="58"  width="58" />
    <icon platform="ios" src="www/res/icon/ios/icon-small@3x.png" height="87"  width="87" />
    <splash src="splash.png" width="320" height="480" />

    <!-- iPhone and iPod touch -->
    <splash src="www/res/splash/ios/default.png" platform="ios" width="320" height="480" />
    <splash src="www/res/splash/ios/default@2x.png" platform="ios" width="640" height="960" />

    <!-- iPhone 5 / iPod Touch (5th Generation) -->
    <splash src="www/res/splash/ios/default-568h@2x.png" platform="ios" width="640" height="1136" />

    <!-- iPhone 6 -->
    <splash src="www/res/splash/ios/default-667h@2x.png" platform="ios" width="750" height="1334" />
    <splash src="www/res/splash/ios/default-portrait-736h@3x.png" platform="ios" width="1242" height="2208" />
    <!--<splash src="www/res/splash/ios/default-landscape-736h@3x.png" platform="ios" width="2208" height="1242" />-->

    <!-- iPad -->
    <splash src="www/res/splash/ios/default-portrait.png" platform="ios" width="768" height="1024" />
    <!--<splash src="www/res/splash/ios/default-landscape.png" platform="ios" width="1024" height="768" />-->

    <!-- Retina iPad -->
    <splash src="www/res/splash/ios/default-portrait@2x.png" platform="ios" width="1536" height="2048" />
    <!--<splash src="www/res/splash/ios/default-landscape@2x.png" platform="ios" width="2048" height="1536" />-->
</platform>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接