I have a view which is subview of a keyWindow (as you can see in the below code). I would like to show an alertController on top of this view (myView
).
I tried to present alertController on the topViewController (as you can see below), this did not work since the view I have is not part of the topViewController.
How can I present alertController on top of a view ?
This is how I added a view to the keyWindow
guard let window = UIApplication.shared.keyWindow else{
return
}
window.addSubview(myView)
The below did not work since the view is not part of the topViewController.
guard let vc = UIApplication.topViewController() else { return}
vc.present(alertController, animated: true, completion: nil)