How can I delay splash launch screen programmatically in Swift Xcode iOS

后端 未结 6 1982
后悔当初
后悔当初 2021-01-31 19:01

I have put an image in imageView in LaunchStoreyboard. How can I delay the time of image programmatically?

Here is the Lau

6条回答
  •  感动是毒
    2021-01-31 19:57

    Definitely your app should not be put to sleep as it may be killed by the OS for being unresponsive for so long.

    If you're using a static image for your launch screen, what works for me is to use the image in the LaunchScreen.storyboard, and then when your main controller launches, modally present a VC with the same image as the background in the ViewDidAppear of your main controller (with animated set to false).

    You can then use your logic to know when to dismiss the launch screen (dismiss method in the VC with animated set to false).

    The transition from the actual LaunchScreen to my VC presenting the same screen looks to me imperceptible.

    PS: the ViewDidAppear method might be called more than once, in which case you need to use logic to not present the VC with the launch screen a second time.

提交回复
热议问题