Try to search your question here, if you can't find : Ask Any Question Now ?

SwiftUI – Date Picker not showing correctly

HomeCategory: stackoverflowSwiftUI – Date Picker not showing correctly
Avatargaurav asked 5 days ago

I´ve created a DatePicker element in SwiftUI, but the DatePicker opens inside the view instead of a sheet at the bottom. (Screenshot below)

enter image description here

My code:

@ObservedObject private var report = Report(
    id: 0,
    timestamp: Date(timeIntervalSinceReferenceDate: 118800),
    date: Date(timeIntervalSinceReferenceDate: 118800),
)


Section(header: Text("Allgemeine Daten")) {
    HStack {
        Label(string: "Name")
        Divider()
        TextField("Name", text: $person.name)
    }
    HStack {
        Label(string: "Monat")
        Divider()
        DatePicker(selection: $report.date, displayedComponents: .date) {
            Text("Select a date")
        }

    }
}

The Section is inside a NavigationView and Form. What could be the issue?

1 Answers
Best Answer
AvatarMikhail answered 5 days ago
Your Answer

3 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com