IOS state preservation: can I display a launch image instead of a snapshot

656 Views Asked by At

Question: When working with IOS state preservation, how can I display a custom launch image instead of the snapshot during the launching process

Description: I am working on IOS state preservation. Everything works fine except that every time I reopen the APP after killing it, the first thing the APP displays is the snapshot of the screen when the app enters background. I have a map view showing user's current location. I don't want the app to show the snapshot of an old location during launching and then jump to the current location. Is there some method to show a custom launch image during the launching process.

2

There are 2 best solutions below

3
quellish On BEST ANSWER

See the documentation for ignoreSnapshotOnNextApplicationLaunch :

As part of the state preservation process, UIKit captures your app’s user interface and stores it in an image file. 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. If you feel that the snapshot cannot correctly reflect your app’s user interface when your app is relaunched, you can call this method to prevent that snapshot image from being taken. If you do, UIKit uses your app’s default launch image instead.

You must call this method from within the code you use to preserve your app’s state.

0
user3688101 On

You can show a launch image when the app first starts up, I believe it's called 'launchImage', but it's a static picture. Apple encourages developers to use a launch image to show the user the UI while the app loads. Because you don't know if the OS will kill your app when it's in the background, and the user is traveling to different locations, it would not be possible to have the current location always ready to go when the app is brought to the forefront. You could show the user something else during the seconds it takes the GPS to get the coord's. You could put it in 'viewWillAppear'.