在这个帖子的帮助下,我能够解决这个问题:Launch Image not showing up in iOS application (using Images.xcassets)
所以我会深入解释它以防它可以帮助其他人。
首先,您需要创建某些图像。我用的是这个模板和这个带有自动生成器的网页:TiCons
当我下载我的图片时,我拿走了 assets/iphone 文件夹中的那些,我只拿了那些:
-
Default@2x.png (640x960)
-
默认-568h@2x.png (640x1136)
-
默认 667h@2x.png (750x1334)
-
Default-Portrait-736h@3x.png (1242x2208)
-
Default-Landscape-736h@3x.png (2208x1242)
你还需要这个 Contents.json 文件在同一个文件夹中,我从朋友那里得到的:
{
"images": [
{
"extent": "full-screen",
"idiom": "iphone",
"filename": "Default-568h@2x.png",
"minimum-system-version": "7.0",
"orientation": "portrait",
"scale": "2x",
"subtype": "retina4"
},
{
"extent": "full-screen",
"idiom": "iphone",
"filename": "Default-667h@2x.png",
"minimum-system-version": "8.0",
"orientation": "portrait",
"scale": "2x",
"subtype": "667h"
},
{
"extent": "full-screen",
"idiom": "iphone",
"filename": "Default-Landscape-736h@3x.png",
"minimum-system-version": "8.0",
"orientation": "landscape",
"scale": "3x",
"subtype": "736h"
},
{
"extent": "full-screen",
"idiom": "iphone",
"filename": "Default-Portrait-736h@3x.png",
"minimum-system-version": "8.0",
"orientation": "portrait",
"scale": "3x",
"subtype": "736h"
},
{
"extent": "full-screen",
"idiom": "iphone",
"filename": "Default@2x.png",
"minimum-system-version": "7.0",
"orientation": "portrait",
"scale": "2x"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
所以,此时我在我的 React Native 项目的 Images.xcassets 文件夹中创建了一个名为 LaunchImage.launchimage 的文件夹,并保存图像和 Contents .json 里面的文件:
其次,您必须在 Xcode 中打开您的项目,并在“常规”设置中,在“应用程序图标和启动图像”下方,我们必须保留选项“LaunchScreen File”为空(我们也可以删除我们项目中的LaunchScreen.xib文件),然后点击“Use Asset Catalog” .将打开一个模式,我们选择 Migrate 目录 Images
现在,在“Launch Images Source”选择器中,我们可以选择我们之前创建的文件夹,LaunchImage(包含我们图片的那个):
我们选择这个而不是 Brand Assets,我们可以删除 Brand Assets 文件夹。
此时,我们将能够使用自定义启动图像运行我们的 React Native 应用程序:
我知道这对于一个看似简单的任务来说似乎有点复杂,但在阅读了很多关于它的内容后,这是我可以让我的启动图像正常工作的唯一方法,所以我想与社区分享。