2016-12-02 68 views
3

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

// 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/[email protected]~ipad.png" width="1536" /> 
    <gap:splash gap:platform="ios" height="2048" src="res/screen/ios/[email protected]~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/[email protected]~ipad.png" width="2048" /> 
</platform> 

然后我用在“终端”下面的命令来生成iOS平台

phonegap build ios --device 

它会将所有飞溅图像iOS平台。

但是,当我启动应用程序时,它显示默认Phonegap启动屏幕图像。我检查了iOS项目'Images.xcassets' - >'LaunchImage,它显示默认PhoneGap图像。它没有显示我在Config.xml文件中提到的splash图像。如何使用​​3210设置iOS

+0

显示或使用ngCordova插件'$ cordovaSplashscreen' – young

+0

选中此http://ngcordova.com/docs/plugins/splashscreen/ – young

+0

检查这也HTTPS隐藏闪屏:// cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ – young

回答

4

首先添加闪屏插件

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/[email protected]" platform="ios" width="1536" height="2048" /> 
<splash src="www/res/screen/ios/[email protected]" platform="ios" width="2048" height="1536" /> 

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

确保图像,因为它是在config.xml中定义宽度高度应该是相同的。

或尝试默认splashscreen。

只是保持你的config.xml所在的全尺寸初始屏幕图像,它将复制所有平台的splash.png文件,不建议这会增加应用程序的大小,但是你可以检查它是否有效。

干杯。

+0

我已经在项目中安装了'cordova-plugin-splashscreen'插件。此外,我已经检查图像大小,这是正确的预期。仍然显示默认的phonegap初始屏幕图像 – Rohit

+0

正好写入我已经写在config.xml中的行,然后尝试它。 –

+0

我只为iPad开发应用程序。你能为我提供iPad的细节吗? – Rohit

0

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

相关问题