使用未解析的标识符 'PresentationButton'

Use of unresolved identifier 'PresentationButton'

使用未解析的标识符 'PresentationButton',是否为 'PresentationButton' 引入了新的 Class?

有没有人在他们的代码中使用过 'PresentationButton'。我想在单击图像或内容框架时打开一个视图。


PresentationButton(destination: ContentView()) {
    CourseView()
}

我确实试图在苹果开发者网站上找到文档,但我没有看到任何文档。

PresentationButton 已弃用。如果你想展示一个 sheet 使用下面的东西。

struct ModalExample: View {
    @State var show = false

    var detail: ModalView {
        return ModalView()
    }

    var body: some View {
        VStack {
            Button("Present") {
                self.show = true
            }
        }
        .sheet(isPresented: $show, content: { ModalView() })
    }
}

struct ModalView : View {
    @Environment(\.presentationMode) var presentationMode

    var body: some View {
        VStack {
            Text("Modal")
            Button("Close") {
                self.presentationMode.value.dismiss()
            }
        }
    }
} 

如果您没有以模态方式显示视图(在这种情况下 .sheet 是可行的方法),Xcode 11 beta 5 中的首选方式是使用 NavigationLink

NavigationLink(destination: ContentView()) {
            Text("show ContentView")
        }