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?
Display the current date and time in a date picker Click the Data tab. In the Data type box, click Date and Time (dateTime). Click Format. In the Date and Time Format dialog box, in the Display the time like this list, click the option that you want, and then click OK.
Android provides controls for the user to pick a time or pick a date as ready-to-use dialogs. Each picker provides controls for selecting each part of the time (hour, minute, AM/PM) or date (month, day, year).
On an Access form, use the Date Picker to enter the current date. If the field is set up as a Date/Time field, the Date Picker icon appears when you click in the field. Click the icon, and then click the Today button below the calendar.
But iOS 14 introduced a whole new date picker we can use. It’s much easier and flexible to use for our end users, and we don’t have to do much to adopt it.
Instead, the calendar or time picker component will be there in all its glory ready to be used. Finally, in either .inline or .compact modes, your user can tap the top right label that shows the month and year and the system will show a wheel picker to let them quickly jump to a different month and year:
Before iOS 14, we should assign a target method to be called on every UIButton created programmatically, and we also needed to implement that method separately. For example, a button would have to be initialized like this: And the doSomething () method shown in the selector should be implemented separately: @objc func doSomething () { ... }
UIDatePicker is an API that has existed since the very early days of the iOS SDK - it goes all the way back to iOS 2.0. If you have been developing for iOS for a while, you must remember this beauty: In iOS 7, the whole system received a full redesign. Look at the huge update our old friend UIDatePicker went through: …
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.stack.imgur.com/k4AKF.jpg)
I had the same issue, and on my side was a problem with how I was adding the picker inside of the cell.
Check you are doing self.contentView addSubview:
not self addSubview
.
I had the same issue. In my case problem was in UITapGestureRecognizer, which I've add to hide keyboard.
This code fixed my problem:
tapGesture.cancelsTouchesInView = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With