是否动态关闭工作表错误后无法单击NavigationBarItems?

时间:2020-04-07 11:37:29

标签: swift swiftui

我有带有NavigationBarItems按钮的NavigationView。 Button调用一个工作表,通常我可以通过向下拖动来关闭它,然后单击按钮再次打开。

问题:如果我在工作表内单击按钮退出面板,则无法再单击面板上的按钮。

struct ContentView: View {

    @State private var showSheet = false

    var body: some View {
        NavigationView {
            Text("Hello World")
                .navigationBarTitle("Mapp")
                .navigationBarItems(trailing: Button(action: showSheetFunc) {
                        Image(systemName: "plus").padding(5)
                })
                .sheet(isPresented: $showSheet) {
                    SheetView(showSheet: self.$showSheet)
            }
        }

    }

    private func showSheetFunc() {
        self.showSheet = true
    }
}

struct SheetView: View {
    @Binding var showSheet: Bool

    var body: some View {
        Button(action: { self.showSheet = false}) {
            Text("Close Me")
        }
    }
}

我制作了一段视频来说明问题。最后,当我单击按钮时,什么也没发生。

https://streamable.com/tza9v4

1 个答案:

答案 0 :(得分:1)

为按钮图像添加更多填充,例如:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Custom Cursor</title>
</head>
<body>

</body>
</html>