小编Lou*_*ure的帖子

如何在 swift ui 中显示两个警报,一个接着另一个

我想制作一个应用程序,用户按下一个按钮,然后当他们选择一个选项时,会弹出另一个警报。当我尝试类似的事情时;

struct ContentView: View {
@State private var showingAlert = false
@State private var showingAlertII = false

var body: some View {
        Button(action: {
            self.showingAlert = true
        }, label: {
            Text("button")
                .alert(isPresented: $showingAlert) {
                    Alert(title: Text("Option one or two"), message: Text("choose"), primaryButton: .default(Text("one"), action: {

        // do some specific actions
                        self.showingAlertII = true
                    }), secondaryButton: .default(Text("two"), action: {
                       //do some other stuff
                        self.showingAlertII = true
                    }))

            }
            .alert(isPresented: $showingAlertII) {
                    Alert(title: Text("Option A or B"), message: Text("choose"), primaryButton: .default(Text("Split"), action: …
Run Code Online (Sandbox Code Playgroud)

swift swiftui

1
推荐指数
1
解决办法
1100
查看次数

标签 统计

swift ×1

swiftui ×1