We have met a problem with iPadOS 17.1.
We have a normal DatePicker to choose the date, but in the meantime, we added an onTapGesture to it and did something.
With the previous version 17.0, when we click the DatePicker, the calendar view is poping up and let's us choose the date. But when we updated to 17.1, the calendar is not shown with a normal click, only a long press gesture will trigger it.
Here is the sample code:
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
DatePicker("test", selection: .constant(Date()), displayedComponents: .date)
.onTapGesture {
print("on tap")
}
}
}
The expectation is the calendar should be shown when the picker is tapped.
You could try a different approach to do something after the date has been selected, using
.onChange(..), instead of relying on the other tap guesture.For example: