Reputation: 6049
I have a SwiftUI Form
with a Section
that contains a DatePicker
. The DatePicker
is set to have a datePickerStyle
of CompactDatePickerStyle()
, by default, since it's in a Form
.
When tapping on the DatePicker
, the overlay is presented:
The DatePicker
's time is able to be modified by using a gesture, as seen in the following video:
In the following video, tapping on the overlaid DatePicker
's time to modify it via the keyboard causes the overlay to be dismissed:
I have also tried adding the following to the DatePicker
in order to allow for inline date manipulation, hoping for keyboard avoidance:
.datePickerStyle(GraphicalDatePickerStyle())
.ignoresSafeArea(.keyboard, edges: .bottom)
However, the above results in the following:
What do I need to change to allow the DatePicker
to be manipulated via gestures and keyboard input within the form?
Upvotes: 6
Views: 1564
Reputation: 139
Did you try to use .ignoresSafeArea(.keyboard) on the entire Form? I had the same issue and this fixed it for me.
Upvotes: 1
Reputation: 377
You need to raise the datepicker so the keyboard wouldn't show over the datepicker, already reported this bug in October 2020 and the ticket is still open. These datepicker don't have keyboard avoidance. Also found an issue with GraphicalDatePickerStyle that can crash the app, ticket still open too.
Upvotes: 1