English 中文(简体)
当我在屏幕上使用一台全色扫描器和一台日期照相机时,在开放的日历上排除全部屏幕,不会留下完整的屏幕。
原标题:When I use a .fullScreenCover and a DatePicker on the screen, dismissing the full screen with the calendar open will not leave the fullscreen
  • 时间:2021-12-03 17:13:27
  •  标签:
  • swiftui

As long as the datePicker selection is closed, everything is fine. When the calendar sheet is left open, and the dismiss (.onTapGesture) is pressed, the onDismiss closure is done, but the screen will not return. Tried setting the isPresenting to false in the didDismiss() with the same results.

getting this error

[序言] ∗∗∗∗∗

参考了这些文件,并增加了一个日期,使事情变得简单。

     struct FullScreenCoverPresentedOnDismiss: View {
     @State private var isPresenting = false
     @State private var birthDate = Date()
     var body: some View {
         Button("Present Full-Screen Cover") {
             isPresenting.toggle()
         }
         .fullScreenCover(isPresented: $isPresenting,
                          onDismiss: didDismiss) {
             VStack {
                 DatePicker(selection: $birthDate, in: ...Date(), displayedComponents: .date) {
                     Text("Select a date")
                 }
                 Text("A full-screen modal view.")
                     .font(.title)
                 Text("Tap to Dismiss")
                     .onTapGesture {
                                          isPresenting.toggle()
                                      }
             }

             .foregroundColor(.white)
             .frame(maxWidth: .infinity,
                    maxHeight: .infinity)
             .background(Color.blue)
             .ignoresSafeArea(edges: .all)
         }
     }

     func didDismiss() {
         print("didDismiss")
     }
 }
问题回答

我发现的唯一工作是总结你想在被解雇日期之后提出的事情。

// Adjust the delay as needed (I ve used 0.25 secs with success) 
DispatchQueue.main.asyncAfter(deadline: .now() + delayInSeconds) { 
    showingConfirmationDialog = true
}




相关问题
SwiftUI: How do I position a button x points above a sheet?

I am trying to recreate a Maps-style UI with a persistent bottom sheet and controls fixed above. Apple Maps UI with controls above ☝️ Example here, the "Look Around" binoculars button and ...

How to access own window within SwiftUI view?

The goal is to have easy access to hosting window at any level of SwiftUI view hierarchy. The purpose might be different - close the window, resign first responder, replace root view or ...

热门标签