Open UIDatePicker programmatically in iOS 14

אורי orihpt picture אורי orihpt · Aug 9, 2020 · Viewed 12.7k times · Source

I have this normal UIDatePicker (sorry that it's not in English, please ignore that):

my date picker

But the problem is that it only appears when I'm pressing the Date Picker:

image

And I wanted to know how to show the Date Picker like in the first image (that it's covering all the screen with the blur effect) only with code, so the user won't need to press the Date Picker to show the date selector. Thanks.

Answer

Blazej SLEBODA picture Blazej SLEBODA · Oct 3, 2020

It's impossible to open a UIDatePicker with UIKit14 from within the code

  • UIDatePicker has no API for doing this
  • UIKit doesn't allow us to create a UIEvents or UITouch object which has any impact on UIKit.