iosswiftuidatepickerios14

Unable to Tap Days in iOS 14 inline DatePicker


I'm trying to create an expandable/collapsible date picker (similar to Apple's date picker in the Date & Time section of the Settings app). I have a tableview that can have a button as one of its table cells. That button shows the currently picked date as its title. Tapping on that button will add a table cell below the button with the new iOS 14 inline date picker.

The issue I'm facing is that I can interact with the date picker by changing the month and year, but the selected day doesn't change when I tap on different days. I added a target on valueChanged and the selector method is triggered when I change the month and year, but not when I choose a different day.

I saw there was a similar question on StackOverflow, but the OP deleted it for some reason.

The table cell containing the date picker is simple. I am dequeueing the cell from its own xib and the xib only contains a view with the date picker inside it. I am not setting the height of the date picker cell, but just using UITableView.automaticDimension to get self-sizing cells. I also looked at the view hierarchy and there isn't anything in front of the date picker, so the touches should be sent to the date picker.

Has anyone else had this issue?

enter image description here


Solution

  • Just had the same issue, my calendar worked fine initially and eventually stopped working, the UIDatePicker was inside a UIView added through storyboard inside The main View.

    Everything worked fine and I could click on the month and year and swipe months left and right. But when trying to click on a day nothing would happen. A new selection could not be made.

    In my case reason behind it was adding a tapGesture to my main view for hiding keyboard. This made the calendar days unselectable.

    (https://i.sstatic.net/k4AKF.jpg)