简体   繁体   English

为什么选择iOS启动屏幕,然后是快照,然后是主屏幕?

[英]Why iOS Launch Screen then Snapshot then Home Screen?

When I kill my iOS app and relaunch it, the quick sequence of screens I see are 当我杀死我的iOS应用并重新启动时,看到的快速屏幕序列是

  1. Launch Screen. 启动屏幕。 The screen defined in LaunchScreen.storyboard . LaunchScreen.storyboard定义的屏幕。
  2. Snapshot. 快照。 The screen image the iPhone created the last time my app was put in the background. iPhone上次将我的应用程序置于后台时创建的屏幕图像。
  3. Home Screen. 主屏幕。 The ViewController that I set in AppDelegate 's application(_:didFinishLaunchingWithOptions:) method. 我在AppDelegateapplication(_:didFinishLaunchingWithOptions:)方法中设置的ViewController

From the Apple documentation that I've read, it seemed that during application launch, if a snapshot exists then iOS uses that snapshot instead of the launch screen. 根据我阅读的Apple文档,似乎在应用程序启动期间,如果存在快照,则iOS使用该快照而不是启动屏幕。 Why am I seeing both the launch screen and the snapshot? 为什么同时看到启动屏幕快照?

This screen recording shows the issue. 此屏幕录像显示了问题。 The launch screen is red. 启动屏幕为红色。 The home screen is white. 主屏幕为白色。 The second screen is green. 第二个屏幕为绿色。 I navigate to the green screen and then put the app in the background to get iOS to take a green screenshot. 我导航到绿色屏幕,然后将应用程序置于后台,以使iOS拍摄绿色屏幕截图。 Then I kill the app. 然后我杀死了应用程序。 When the app is relaunched, the sequence is launch/red, flash of screenshot/green, home/white. 重新启动应用程序时,顺序为启动/红色,屏幕截图/绿色,首页/白色。 I'm testing on an iPhone 6 with iOS 12.1.1. 我正在使用iOS 12.1.1的iPhone 6进行测试。

https://imgur.com/a/EMX4dM1 https://imgur.com/a/EMX4dM1

From https://developer.apple.com/documentation/uikit/uiapplication/1623097-ignoresnapshotonnextapplicationl 来自https://developer.apple.com/documentation/uikit/uiapplication/1623097-ignoresnapshotonnextapplicationl

As part of the state preservation process, UIKit captures your app's user interface and stores it in an image file. 作为状态保存过程的一部分,UIKit捕获应用程序的用户界面并将其存储在图像文件中。 When your app is relaunched, the system displays this snapshot image in place of your app's default launch image to preserve the notion that your app was still running. 重新启动您的应用程序时,系统将显示此快照图像代替您应用程序的默认启动图像,以保留您的应用程序仍在运行的概念。

I can't confirm your description. 我无法确认您的描述。 My testing shows that if you kill your app prematurely, then on the next launch the previous backgrounding screen shot is thrown away and the launch screen alone is used. 我的测试表明,如果您过早终止应用程序,则在下次启动时,将丢弃之前的背景屏幕截图,仅使用启动屏幕。

Here is my test: 这是我的测试:

  • The launch screen is red 启动屏幕为红色

  • The initial view controller's view is white 初始视图控制器的视图为白色

  • The secondary view controller's view is green 辅助视图控制器的视图为绿色

Here is what happens: 这是发生了什么:

  1. You will see me launch and then move from the white view to the green view. 您将看到我启动,然后从白色视图移至绿色视图。

  2. I then background the app to make sure the snapshot is taken. 然后,我将应用程序设为背景,以确保已拍摄快照。

  3. I then bring the app back to the foreground and then go into the app launcher so you can see the snapshot, which is indeed green. 然后,我将应用程序带回前台,然后进入应用程序启动器,以便可以看到快照,该快照的确是绿色的。

  4. Then I kill the app and relaunch it. 然后,我杀死了该应用程序并重新启动它。 I used slow motion in this part of the movie, and you can see clearly that we use the red launch screen and fade to the white of the initial view controller; 我在电影的这一部分中使用了慢动作,您可以清楚地看到我们使用红色的启动屏幕,并淡化为初始视图控制器的白色。 the green never reappears. 绿色永远不会消失。

在此处输入图片说明

Perhaps your testing procedure is faulty (test only on a device). 也许您的测试过程有误(仅在设备上进行测试)。 Perhaps you are launching into the wrong screen and then jumping back to the opening screen (that seems the most likely explanation). 也许是在错误的屏幕中启动,然后跳回到打开的屏幕(这似乎是最可能的解释)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM