2016-12-02 66 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 /)中的圖像文件。 默認情況下,它包含的電話缺口圖像

相關問題