You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've always believed that UIAlertController views were presented in their own window. Turns out I was mistaken. You're going to need to present the UIAlertController in its own window, which will sit above Instructions' window. By default, Instructions uses a window with the following level: UIWindowLevelNormal + 1 (it's customizable, but not yet in the README). The custom window will need to have an higher value than that.
Here's a possible way to achieve what, from the top of my head (untested).
letwindow=UIWindow(frame:UIScreen.main.bounds)letdummyViewController=UIViewController()
dummyViewController.view.backgroundColor =UIColor.clear
window.rootViewController = dummyViewController
window.windowLevel = UIWindowLevelNormal +2
// Instructions doesn't use a key window, but the alert probably should.
window.makeKeyAndVisible()
dummyViewController.present(alertViewController, animated:true, completion:nil)
After the alert is dismissed, we'll probably need to make sure that the key window is again the main window, and not the one used by Instructions. It's most likely done automatically, but I haven't checked.
I've always believed that UIAlertController views were presented in their own window. Turns out I was mistaken. You're going to need to present the UIAlertController in its own window, which will sit above Instructions' window. By default, Instructions uses a window with the following level: UIWindowLevelNormal + 1 (it's customizable, but not yet in the README). The custom window will need to have an higher value than that.
Here's a possible way to achieve what, from the top of my head (untested).
letwindow=UIWindow(frame:UIScreen.main.bounds)letdummyViewController=UIViewController()
dummyViewController.view.backgroundColor =UIColor.clear
window.rootViewController = dummyViewController
window.windowLevel = UIWindowLevelNormal +2
// Instructions doesn't use a key window, but the alert probably should.
window.makeKeyAndVisible()
dummyViewController.present(alertViewController, animated:true, completion:nil)
After the alert is dismissed, we'll probably need to make sure that the key window is again the main window, and not the one used by Instructions. It's most likely done automatically, but I haven't checked.
Activity
ephread commentedon May 18, 2017
Hello @Salmancs43, sadly, nothing can be done at the moment. But there's hope, next version will ship with proper support of window levels.
ephread commentedon Jun 3, 2017
I've always believed that
UIAlertController
views were presented in their own window. Turns out I was mistaken. You're going to need to present theUIAlertController
in its own window, which will sit above Instructions' window. By default, Instructions uses a window with the following level:UIWindowLevelNormal + 1
(it's customizable, but not yet in the README). The custom window will need to have an higher value than that.Here's a possible way to achieve what, from the top of my head (untested).
After the alert is dismissed, we'll probably need to make sure that the key window is again the main window, and not the one used by Instructions. It's most likely done automatically, but I haven't checked.
Salmancs43 commentedon Jun 5, 2017
It Can be achieved using this code.
ephread commentedon Jun 5, 2017
Problem solved!
kennenfromchina commentedon Dec 25, 2018
perfect!