English 中文(简体)
放弃姿态的延误打破了随后的陈述
原标题:Sheet dismiss gesture delay breaks subsequent sheet presentation

目前,我正在撰写一个利用快速倡议的项目,每个纽芬兰文在一份清单中都呈报。 如果我不使用被解职的县,并在名单上选择另一个县,则该表没有问题。

然而,如果我放弃,试图很快在名单上选择另一个纽州,那么除非我再次利用纽州,否则该表就没有显示。

我对这一点做了一些测试,我发现,当我放弃表板后操纵纽特权时,尽管表上没有显示,但<代码>isPresented<>/code>依然有效。

我的结论认为,如果出现一个解职,is Presented就立即被定为伪造,但用一种pe塞的姿态予以驳回,在更新时,明显延误。 我将如何把这一拖延从沉积姿态中删除?

I tried using sheet(item: ) as well, but some buttons tend to not present a sheet if I quickly dismiss and press a button.

样本代码如下。 首先,出示该表,以wi子姿态予以驳回,并迅速在名单上选择另一个纽州(或同一个纽州)。 页: 1

// Comment out the ContentView that you don t want to present
struct SheetItem: Identifiable {
    let id: UUID = UUID()
    let name: String
}

struct ContentView: View {
    let items = [
        SheetItem(name: "John"),
        SheetItem(name: "Dylan"),
        SheetItem(name: "Dave")
    ]

    @State private var isPresented = false
    @State private var selectedItem: SheetItem?

    var body: some View {
        NavigationView {
            List {
                Section("Uses isPresented for the sheet") {
                    ForEach(items, id: .id) { item in
                        Button(item.name) {
                            // This shows the sheet presentation state on button press
                            // print(isPresented)
                            selectedItem = item
                            isPresented.toggle()
                        }
                    }
                }
            }
            .navigationTitle("Results")
        }
        .sheet(isPresented: $isPresented) {
            if let item = selectedItem {
                SheetView(item: item)
            } else {
                Text("Item not selected?")
            }
        }
    }
}

struct ContentView: View {
    let items = [
        SheetItem(name: "John"),
        SheetItem(name: "Dylan"),
        SheetItem(name: "Dave")
    ]

    @State private var isPresented = false
    @State private var selectedItem: SheetItem?

    var body: some View {
        NavigationView {
            List {
                Section("Uses isPresented for the sheet") {
                    ForEach(items, id: .id) { item in
                        Button(item.name) {
                            // This shows the sheet presentation state on button press
                            // print(selectedItem)
                            selectedItem = item
                        }
                    }
                }
            }
            .navigationTitle("Results")
        }
        .sheet(item: $selectedItem) { item in
            SheetView(item: item)
        }
    }
}

struct SheetView: View {
    @Environment(.dismiss) var dismiss
    var item: SheetItem

    var body: some View {
        VStack {
            Text("Hello, (item.name)")
            Button("Dismiss") {
                dismiss()
            }
        }
    }
}

“entergraph

问题回答

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

// 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, ...