0

We're currently migrating from the deprecated UIAlertView to UIAlertController.

Our application can react the certain external events (such as push notifications, bluetooth communication, background network responses) and as a result of those events it can present at any moment a new UIViewController on top of the top most view controller.

However, since migrating to UIAlertController, we've encountered scenarios where an UIAlertController is presented right before another UIViewController should be presented, since they are triggered by different events.

Since we're relying on the top most view controller, this means that the UIAlertController will present another UIViewController instance, which isn't what we want, because the UIAlertController is not visible any longer.

Is there a way to keep presenting the UIAlertController at the window level, just like the deprecated UIAlertView works?

In this way we would make sure that the UIAlertController is always on top and it can't actually present another UIViewController.

Thank you, Cosmin

Cosmin
  • 2,840
  • 5
  • 32
  • 50
  • I’ve found something interesting - it seems that this library takes the approach of subclassing UIAlertController an creating a new window - https://github.com/sspbond007/JSAlertView/blob/master/JSAlertView/JSAlertView/JSAlertView.m . I'll look more into it. – Cosmin Oct 26 '17 at 09:15
  • In the end I've taken the UIAlertController extension approach, that uses a dedicated UIWindow runtime property from here - https://stackoverflow.com/questions/26554894/how-to-present-uialertcontroller-when-not-in-a-view-controller This can be closed a a duplicate. – Cosmin Oct 26 '17 at 13:44
  • Possible duplicate of [How to present UIAlertController when not in a view controller?](https://stackoverflow.com/questions/26554894/how-to-present-uialertcontroller-when-not-in-a-view-controller) – Cosmin Oct 26 '17 at 13:45

0 Answers0