dillidon/alerts-and-pickers

whose view is not in the window hierarchy

dajdouj10 opened this issue · 2 comments

Warning: Attempt to present <UIAlertController: 0x7fc45081c800> on <App_iOS.AccueilViewController: 0x7fc44f507420> whose view is not in the window hierarchy!

I have not looked in detail because it does not work, but try to call it another way and I showed it, instead of using .show (), use the self.present and it works!


let alert = UIAlertController (style: .actionSheet, title: "Date Picker", message: "Select Date")
         alert.addDatePicker (mode: .dateAndTime, date: Date (), minimumDate: nil, maximumDate: nil) {date in
             Log (date)
         }
         alert.addAction (title: "Done", style: .cancel)
         //alert.show ()
         self.present (alert, animated: true, completion: nil)

I have not looked in detail because it does not work, but try to call it another way and I showed it, instead of using .show (), use the self.present and it works!


let alert = UIAlertController (style: .actionSheet, title: "Date Picker", message: "Select Date")
         alert.addDatePicker (mode: .dateAndTime, date: Date (), minimumDate: nil, maximumDate: nil) {date in
             Log (date)
         }
         alert.addAction (title: "Done", style: .cancel)
         //alert.show ()
         self.present (alert, animated: true, completion: nil)

thank you worked