I've been trying without any luck to implement state restoration and preservation.
I'm not using storyboards. I have to be doing something wrong.
I set up the restoration identifier for every Nib file.
I know the state is being stored, but never restored properly. The last state shows for half a second and then it goes back to the main view. I've tried many things with no luck. Please help!
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"will finish");
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
navigator = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navigator;
[self.window makeKeyAndVisible];
[navigator release];
NSLog(@"did finish");
return YES;
}
// As you can see, I started the process of saving and restoring application state.
// Also, I added the restoration identifier for every class that should be restored.
-(BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder
{
NSLog(@"restoring");
return YES;
}
-(BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder
{
return YES;
}
-(void)application:(UIApplication *)application didDecodeRestorableStateWithCoder:(NSCoder *)coder
{
NSLog(@"restored");
//navigator = [[UINavigationController alloc] initWithRootViewController:];
isRestored = YES;
}