Pergunta

How would you implement state restoration for a modal or "presented" view controller?

Let's say for example that I have ViewController and SecondViewController. ViewController has a single button. When you click the button, it presents SecondViewController (using a modal segue).

Foi útil?

Solução

The problem is that you recreating your modalVC before you presenting it.

EX: What you're doing

-(IBAction)presentModalVC:(id *)sender{
 ModalVC *modalVC = [self.storyboard instantiateViewControllerWithIdentifier:@"modal"];    
 [self presentViewController:modalVC animated:YES completion:nil];
}

What you need to do:

create property of your modalVC and initialize it in viewDidLoad method

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top