views:

41

answers:

1

hi,

I have a requirement to save the last screen viewed while closing the app so that i can show the same screen when he re-opens the app. Can anyone tell me how to save the view and show it after re-opening ?

+2  A: 

In applicationWillTerminate: and applicationDidEnterBackground:, save enough state to [NSUserDefaults standardUserDefaults] so you can restore the view in the view controller's viewDidLoad method.

Daniel Dickison
Is it possible to just store the actual view which is displayed ? if yes now ?
thndrkiss
You might be able to, but it's not a good idea. You could draw the view to an image, but of course then the restored view would be a static image that you can't interact with. You could also serialize the view hierarchy with NSKeyedArchiver, but this won't work well with many types of views (and if you have custom subviews you will need to implement the NSCoding methods.
Daniel Dickison