You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SwiftUI中弹出Alert后导航栏返回按钮消失问题求助

Alert关闭后导航栏返回按钮消失

我编写了如下极简的AccountView代码:

struct AccountView: View {
    @State private var showingLogoutAlert = false
    var body: some View {
        Button("Log out!") {
            showingLogoutAlert = true
        }
        .alert(isPresented: $showingLogoutAlert, content: {
            Alert(title: Text("Log out of Flow?"),
                  primaryButton: .cancel(),
                  secondaryButton: .destructive(Text("Log out"), action: {
                //logOut()
            }))
        })
        
    }
}

点击按钮会弹出确认登出的Alert,但无论点击Alert的「取消」还是「登出」按钮关闭弹窗后,当前页面导航栏的返回按钮都会消失。我已经将代码精简到最小程度,在全新的SwiftUI应用中也能稳定复现该问题。(动图完整展示流程:进入AccountView页面后点击按钮弹出Alert,关闭Alert后导航栏左侧的返回按钮消失)

内容的提问来源于stack exchange,提问作者Aziz A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 00:25:26