一次在watchOS上使用后,SwiftUI PresentationButton停止运行

Isa*_*aac 6 swiftui

PresentationButton可以正确显示视图,但是在单击“取消”以返回到父视图时,该按钮拒绝再次显示子视图。

这是我的PresentationButton代码:

struct ContentView : View {
    var body: some View {
        ZStack {

            PresentationButton(Text("Click to show"), destination: SomeOtherView())
                .transition(.slide)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Zai*_*ain 1

这个 bug 以各种形式存在,直到 Xcode 11 beta 4,但请注意 API 已经改变。

PresentationButton成为PresentationLink,然后在 Xcode 11 beta 4 中被弃用,取而代之的是.sheet.

有关如何使用新功能的示例,请参阅此处:/sf/answers/3996117961/