Question

Im trying to return to a specific ViewController in it's current state after going from that ViewController to another using presentViewController.

But when I try to close the other ViewController (with dismissViewController) I get a white screen.

RootViewController *rootViewController 
   = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]
             instantiateViewControllerWithIdentifier:@"RootViewController"];
    [self presentViewController:rootViewController animated:YES completion:nil];

This isn't an option either because that instantiates a new viewcontroller and I want the old ViewController in its current state.

Do I need to pass the RootViewController as an argument when presenting the other ViewController or is there another option to return to the RootViewController in its current state?

Was it helpful?

Solution 2

one way to address this is to avoid having one view controller responsible for presenting and dismissing the other one.. what you can do is create a controller of controllers (give it a singelton method).. and have that object basically keep a reference to any view controller you are interested in maintaining its state. That way you wouldn't have worry about what's going on behind the scenes when you dismiss or present a view controller.

OTHER TIPS

Yes, there is a way to return original screen. I met just like problem but solved it with following code line

[self dismissViewControllerAnimated:YES completion:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top