2

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.

ukim
  • 2,395
  • 15
  • 22

2 Answers2

2

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.

quellish
  • 21,123
  • 4
  • 76
  • 83
  • 1
    In other words, you unfortunately can't supply an _arbitrary_ launch image for this special situation; you can just reject the automatic snapshot, in which case the original startup launch image is shown and you will then fade nicely into the actual restored scene. – matt Jul 23 '14 at 21:23
  • It works fine! Thank you @quellish! Could you also tell me how to do this "have your map view not be part of the snapshot taken". – ukim Jul 23 '14 at 21:27
  • 1
    You have to be a bit clever, but you can supply an arbitrary image. http://www.dragthing.com/blog/2009/07/how-to-make-your-iphone-app-launch-faster/ – quellish Jul 23 '14 at 22:03
0

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'.