English 中文(简体)
快速调查 日期 雇主失职?
原标题:SwiftUI DatePicker breaks sheet dismiss?

<>Scenario:

  • RootScreen presents DateScreen modally though .sheet
  • DateScreen has a DatePicker with CompactDatePickerStyle() and a button to dismiss the modal
  • User opens the DatePicker
  • User taps the DatePicker to bring up the NumPad for manual keyboard input
  • User presses the button to dismiss the modal

页: 1 律师联合会将认为<条码>.sheet已被拒绝,但事实上,只有日标人解职。

<>最低代码:

struct DateScreen: View {
    @Binding var isPresented: Bool
    @State var date: Date = Date()

    var body: some View {
        NavigationView {
            VStack {
                DatePicker("", selection: $date, displayedComponents: [.hourAndMinute])
                    .datePickerStyle(CompactDatePickerStyle())
            }
            .navigationBarItems(leading: Button("Dismiss") {
                isPresented = false
            })
        }
    }
}

@main
struct Main: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    @State var isPresenting: Bool = false

    var body: some Scene {
        WindowGroup {
            Button("Present modal", action: {
                isPresenting = true
            })
                .sheet(isPresented: $isPresenting, content: {
                    DateScreen(isPresented: $isPresenting)
                })
        }
    }
}

www.un.org/Depts/DGACM/index_spanish.htm 显示破裂行为:

注:如果用户不打开NumPad,看来工作良好。

“Gif

最佳回答

这是规定代码的问题,State is in Scene,而不是视之为,国家并不是为了更新现场。 快速倡议的正确解决办法是把所有东西从现场移至视野,在那里只有一个根本观点。

用Xcode 13.4 /OS 155进行测试

“demo”/

@main
struct Main: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {
           ContentView()    // << window root view, the one !!
        }
    }
}


struct ContentView: View {
    @State var isPresenting: Bool = false

    var body: some View {
        Button("Present modal", action: {
            isPresenting = true
        })
        .sheet(isPresented: $isPresenting, content: {
            DateScreen(isPresented: $isPresenting)
        })

    }
}

// no more changes needed
问题回答

对15号SOS公司来说,这样做是为了驳回该表,并不产生警告:

<代码>窗户在15.0中折旧: 在相关窗口现场使用IDWindowScene.windows,改为

法典:

UIApplication.shared.connectedScenes
    .filter({$0.activationState == .foregroundActive})
    .compactMap({$0 as? UIWindowScene})
    .first?
    .windows
    .first { $0.isKeyWindow }?
    .rootViewController?
    .dismiss(animated: true)

我发现的唯一工作是忽视迅速调查,回头去调查股进行解雇。

而不是ispresented = 虚假 我不得不做UIApplication. Commond.windows.first?.rootViewController?.dismiss (animated: real)

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

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




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签