Alex L
Alex L

Reputation: 8449

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.

Upvotes: 8

Views: 1895

Answers (2)

Erik Villegas
Erik Villegas

Reputation: 984

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

Upvotes: 3

Sean Kladek
Sean Kladek

Reputation: 4446

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];

Upvotes: 3

Related Questions