如何在PhoneGap中为iOS设置启动画面

3

我正在使用PhoneGap创建iOS9+应用程序。根据指南,我已经在Config.xml中添加了以下代码以设置启动画面。

// set the cordova plugin 
 <plugin name="cordova-plugin-splashscreen" source="npm" spec="&gt;1.0.0" />

 // set splash screen for iPad only
 <platform name="ios">
    <gap:splash gap:platform="ios" height="2048" src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" />
    <gap:splash gap:platform="ios" height="2048" src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" />
    <gap:splash gap:platform="ios" height="768" src="res/screen/ios/Default-Landscape~ipad.png" width="1024" />
    <gap:splash gap:platform="ios" height="1536" src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" />
</platform>

然后我在“终端”中使用以下命令生成iOS平台

phonegap build ios --device

它复制了所有在iOS平台上的启动图片。但是当我启动应用程序时,它显示默认的Phonegap启动屏幕图像。我在iOS项目“Images.xcassets”->“LaunchImage”中检查了一下,它显示了默认的PhoneGap图像。它没有显示我在Config.xml文件中提到的启动图片。我该如何使用config.xml为iOS设置启动图片?

使用ngCordova插件$cordovaSplashscreen显示或隐藏启动画面。 - Mable John
请查看此链接:http://ngcordova.com/docs/plugins/splashscreen/ - Mable John
请查看以下链接:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ - Mable John
我已经检查了链接 https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/,我尝试了文档中提到的两种方式,“Legacy launch images”和“Launch storyboard images”,但仍然显示默认的Phonegap启动画面。 - RohitK
2个回答

5

首先添加启动画面插件。

cordova plugin add cordova-plugin-splashscreen

然后在 config.xml 中添加以下行。

<!-- iOS splash screen -->
<!-- iPad -->
<splash src="www/res/screen/ios/Default-Portrait.png" platform="ios" width="768" height="1024" />
<splash src="www/res/screen/ios/Default-Landscape.png" platform="ios" width="1024" height="768" />
<!-- Retina iPad -->
<splash src="www/res/screen/ios/Default-Portrait@2x.png" platform="ios" width="1536" height="2048" />
<splash src="www/res/screen/ios/Default-Landscape@2x.png" platform="ios" width="2048" height="1536" />

<!-- Default splash screen -->
<splash src="splash.png" />

请确保图像的宽度高度与config.xml中定义的相同。

或者尝试使用默认启动画面。

只需在config.xml所在的位置保留完整大小的启动画面图像,它将为所有平台复制splash.png文件。虽然不建议这样做,因为会增加应用程序的大小,但您可以检查它是否有效。

干杯。


我已经在项目中安装了“cordova-plugin-splashscreen”插件。同时,我已经交叉检查了图像大小,它与预期的一样正确。但仍然显示默认的phonegap启动画面图像。 - RohitK
按照config.xml文件中的设置编写代码并尝试运行。 - Anuj.T
我正在开发仅适用于iPad的应用程序。您能否提供有关iPad的详细信息? - RohitK
我的解决方案对我有效,但需要先使用命令“phonegap platform remove ios”删除iOS平台,然后使用命令“phoengap build ios --device”添加它。 - RohitK

0

您需要更改/替换启动画面目录(www/res/screen/ios/)中的图像文件。 默认情况下,它包含 PhoneGap 的图像。


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