Question

Hello everyone I receive push notification and if the app is active, I give the user an alertview whether he/she wants to view notification or not. If the user selects "yes" then I present a modal and all these are done in the app delegate.

[[[[UIApplication sharedApplication] delegate] window].rootViewController presentModalViewController:EO animated:NO];

So far everything works fine, but when I am in the app and I am on an already presented modal I get the following warning :

Warning: Attempt to present <ABCViewcontroller: 0x201f27f0>  on <SWViewController: 0x1f58c330> which is already presenting <UINavigationController: 0x201d3050>

And i dont see the window presented modally.

Was it helpful?

Solution

A controller can only have one modal presented at a time. A potential quick fix is to dismiss a potential modal first, before showing the new one:

// Dismiss
[self.window.rootViewController dismissViewControllerAnimated:NO completion:nil];

// Then present
[self.window.rootViewController presentViewController:controller animated:YES completion:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top