squimer / DatePickerDialog-iOS-Swift

Date picker dialog for iOS
MIT License
581 stars 177 forks source link

DatePickerDialog don't show when setting entry point programmatically #31

Closed gruenekampfente closed 7 years ago

gruenekampfente commented 7 years ago

Hello everybody!

I have a big problem and hope one of you can help me. When I open my App the first time, with the entry point from the storyboard, everything works fine. But when I open it the second time, where I set the entry point trough the AppDelegate class the dialog don't appear on the screen. I've seen a issue where someone had a similar problem, but there was no solution for this.

Thanks in advance!

gruenekampfente commented 7 years ago

Ok now I've solved it. The problem was that I set the var window: UIWindow? in AppDelegate by myself in the didFinishLaunchingWithOptions Method. To solve this you just need to modify the Datepicker-Show Method. Instead of: UIApplication.sharedApplication().windows.first!.addSubview(self) UIApplication.sharedApplication().windows.first!.bringSubviewToFront(self) UIApplication.sharedApplication().windows.first!.endEditing(true)

Use:

let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate appDelegate.window?.addSubview(self) appDelegate.window?.bringSubviewToFront(self) appDelegate.window?.endEditing(true)

lfarah commented 7 years ago

@gruenekampfente Thanks for fixing it. Can you submitted a pull request to fix this, please?

benjohnde commented 7 years ago

Can also be closed :)