Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dismissViewControllerAnimated results in empty screen

I present modal view which is a navigation controller:

 UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:photoEditVC];
 [self  presentViewController:nvc animated:YES completion:NULL];

Once I'm done with the modal view, inside nvc's visible controller:

[self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];

Result Blank Screen

Any ideas why this could happen?

UPDATE: I realized this only happens when before dismissing the view, I update a value in a shared singleton class, I use to keep track of events.

[[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
[self dismissViewControllerAnimated:YES completion:NULL];

But it works fine if I do this:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
   [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
}];

or I can do this and it also works fine:

[self dismissViewControllerAnimated:YES completion:^{

           [[SAStatus current] setValue:@(ua_photoSubmitted) forKeyPath:@"actions.user"];
 }];

At the time, no other classes observer that variable so I do not understand why it would affect the modal view.

like image 881
Alex L Avatar asked May 17 '13 18:05

Alex L


2 Answers

Not sure that this is causing the black screen, but the presented view controller should call dismissViewController on itself, not on the presenting view controller.

[self dismissViewControllerAnimated:YES completion:nil];
like image 82
Sean Kladek Avatar answered Nov 11 '22 12:11

Sean Kladek


I saw this issue with iOS 8 GM. Dismissing with animated set to NO did the trick.

like image 35
Erik Villegas Avatar answered Nov 11 '22 12:11

Erik Villegas