首页 > 解决方案 > 如何解决swiftUI中的“使用未解析的标识符'PresentationLink'”错误?

问题描述

在 swiftUI 中,我尝试创建 PresentationLink 按钮,但在 beta 5 中更新 xcode 后,出现“使用未解析的标识符 'PresentationLink'”错误。我不知道为什么。

'PresentationLink' 它已被弃用,是否已被其他名称取代?我在文档中没有找到。

xcode的截图

我的代码:

import SwiftUI

struct NavBar : View {
  var body: some View {
    VStack {
      Image("navigation_border")
        .resizable()
        .aspectRatio(contentMode: .fill)
      HStack {
        Spacer()

        // Compass button
        Button(action: {
          // Code here
        }) {
          Image("ic_compass")
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: CGFloat(35), height: CGFloat(35), alignment: .center)
          Text("Boussole")
            .foregroundColor(Color("TextLight"))
            .font(.system(size: 14))
            .fixedSize()
        }
        .frame(height: CGFloat(50), alignment: .bottomLeading)

        Spacer()

        // Travel button
        Button(action: {
          // Code here
        }) {
          Image("ic_travel")
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: CGFloat(35), height: CGFloat(35), alignment: .center)
          Text("Parcours")
            .foregroundColor(Color("TextLight"))
            .font(.system(size: 14))
            .fixedSize()
        }
        .frame(height: CGFloat(50), alignment: .bottomLeading)

        Spacer()

        // Settings button
        PresentationLink(destination: Settings()) {
          Image("ic_settings")
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: 32, height: 32, alignment: .center)
          Text("Paramètres")
            .foregroundColor(Color("TextLight"))
            .font(.system(size: 14))
            .fixedSize()
        }
        .frame(height: 50, alignment: .bottomLeading)

        Spacer()

      }
      .frame(minWidth: 0, maxWidth: .infinity, minHeight: 70, maxHeight: 70, alignment: .center)
    }
    .frame(minWidth: 0, maxWidth: .infinity, minHeight: 90, maxHeight: 90, alignment: .center)
  }
}

我做了 MacOS Catalina 的最新更新。

坦克你的帮助。

标签: swiftxcodeswiftui

解决方案


推荐阅读