【问题标题】:How to set splash screen for iOS in PhoneGap如何在 PhoneGap 中为 iOS 设置启动画面
【发布时间】:2017-04-16 22:45:19
【问题描述】:

我正在使用PhoneGapiOS9+ 创建iOS 应用程序。根据指南,我在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.xmliOS 设置启动图像?

【问题讨论】:

标签: ios cordova splash-screen phonegap-cli launchimage


【解决方案1】:

首先添加启动画面插件

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" />

确保图像widthheight应该与config.xml中定义的一样。

或尝试默认启动画面。

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

干杯。

【讨论】:

  • 我已经在项目中安装了“cordova-plugin-splashscreen”插件。此外,我已经交叉检查了图像大小,它与预期的一样正确。仍然显示默认的 phonegap 初始屏幕图像
  • 写下我在config.xml中写的行,然后试试。
  • 我正在为 iPad 开发应用程序。能否请您提供 iPad 的详细信息?
  • 解决方案对我有用,但需要先使用命令'phonegap platform remove ios'删除iOS平台,然后使用命令'phoengap build ios --device'添加它
【解决方案2】:

您需要更改/替换初始屏幕目录 (www/res/screen/ios/) 中的图像文件。 默认情况下,它包含电话间隙的图像

【讨论】:

    猜你喜欢
    • 2013-04-08
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    相关资源
    最近更新 更多