Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - Execute code on LaunchScreen [duplicate]

In iOS there is an LaunchScreen before you're app is ready. Can you add things to do (Code) to this?

I want to execute a JSON request on LaunchScreen but have no idea where to put the code.

Thanks In Advance, Kaaseter

like image 478
Kaaseter Avatar asked Apr 14 '15 09:04

Kaaseter


1 Answers

As you wrote, LaunchScreen is there before your app is ready and it implies that you can't execute your code in this time.

To achieve something similar, copy & paste content of your LaunchScreen into your initial view controller in your Main storyboard (or whatever you do use) and launch your request in initial view controller and then transition to any other view controller.

User is not going to notice LaunchScreen -> Main transition.

Purpose of LaunchScreen is to just replace splash images with something better where you can use auto layout for example, ... In other words, to minimize your work, so, you're not forced to create splash screen for every device screen size, etc. But you are not allowed to run any logic in LaunchScreen.

like image 148
zrzka Avatar answered Nov 13 '22 12:11

zrzka