Showing UIAlertController on top of MPMediaPickerController



I want to be able to show a UIAlertController on top of a MPMediaPickerController when it is already presented. Right now when I try this, my app doesn’t crash, but I get an error in the console that says “Warning: Attempt to present on whose view is not in the window hierarchy!


The code I’m using to present the alert controller is as follows:


let alert: UIAlertController = UIAlertController(title: "Alert", message: "Message", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "Done", style: .cancel, handler: nil))
            self.present(alert, animated: true, completion: nil)


Nothing pops up on the screen when I try this, but it just gives me the above console error.


How can I overcoe this? Thanks in advance. Any help is appreciated.

Powered by WPeMatico


You may also like...

Comments are closed.