dillidon / alerts-and-pickers

Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...
MIT License
5.67k stars 705 forks source link

whose view is not in the window hierarchy #70

Open dajdouj10 opened 5 years ago

dajdouj10 commented 5 years ago

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

JavierSolis commented 5 years ago

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)
ahmetmvural1 commented 5 years ago

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