目前,我正在撰写一个利用快速倡议的项目,每个纽芬兰文在一份清单中都呈报。 如果我不使用被解职的县,并在名单上选择另一个县,则该表没有问题。
然而,如果我放弃,试图很快在名单上选择另一个纽州,那么除非我再次利用纽州,否则该表就没有显示。
我对这一点做了一些测试,我发现,当我放弃表板后操纵纽特权时,尽管表上没有显示,但<代码>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()
}
}
}
}