【发布时间】:2020-11-08 09:40:27
【问题描述】:
我正在使用NavigationLink“推送”一个新视图,如下所示:
NavigationLink(destination: SomeView(shown: $isActive)), isActive: $isActive) { ... }
在SomeView 内部,我现在可以将shown 设置为false 以“弹出”返回。这行得通。
但是,如果在 SomeView 中显示警报,则不再有效。显示警报时,我还在控制台中收到此错误消息:
popToViewController:transition: called on <_TtGC7SwiftUI41StyleContextSplitViewNavigationControllerVS_19SidebarStyleContext_ 0x7ffc1e858c00> while an existing transition or presentation is occurring; the navigation stack will not be updated.
我做错了什么?
这是我在SomeView 中显示警报的方式:
VStack
{
// ...
}
.alert(isPresented:$showAlert)
{
Alert(title: Text("Some text"), message: Text("More text"), dismissButton: .default(Text("OK")))
}
我通过将 showAlert 设置为 true 来显示警报。
【问题讨论】:
标签: swiftui