Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication state preservation and restoration without using storyboard?
    primarykey
    data
    text
    <p>I have added <code>uinavigationcontroller</code> in <strong>AppDelegate.m</strong> like this</p> <pre><code> self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self.viewController]; nav.restorationIdentifier = @"nav1"; self.window.rootViewController = nav; </code></pre> <p>My <strong>ViewController.m</strong> look like this</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.restorationIdentifier = @"secondViewController"; // Do any additional setup after loading the view, typically from a nib. } -(IBAction)click:(id)sender { secondViewController *svc = [[secondViewController alloc]initWithNibName:@"secondViewController" bundle:nil]; svc.restorationIdentifier = @"secondViewController"; svc.restorationClass = [self class]; [self.navigationController pushViewController:svc animated:YES]; } </code></pre> <p>My <strong>secondViewController.m</strong> like</p> <pre><code>+(UIViewController *)viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder { NSLog(@"viewControllerWithRestorationIdentifierPath"); UIViewController * myViewController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; return myViewController; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; label.text = @"sdfkheiowodhnskjfdgewluri3y2oejdscndjshfiledhdsfhewilufhyeows"; // Do any additional setup after loading the view from its nib. } -(void)encodeRestorableStateWithCoder:(NSCoder *)coder { NSLog(@"encodeRestorableStateWithCoder"); [coder encodeObject:label.text forKey:@"UnsavedText"]; [super encodeRestorableStateWithCoder:coder]; } -(void)decodeRestorableStateWithCoder:(NSCoder *)coder { NSLog(@"decodeRestorableStateWithCoder"); [super decodeRestorableStateWithCoder:coder]; label.text = [coder decodeObjectForKey:@"UnsavedText"]; } </code></pre> <p><strong>In Output</strong></p> <p>I get encodeRestorableStateWithCoder but after this when I press home button and then again run application my application state not present secondViewController and decodeRestorableStateWithCoder not get called.</p> <p>I dont know where I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload