【问题标题】:Can't click a NavigationLink in List (SwiftUI)无法单击列表中的 NavigationLink (SwiftUI)
【发布时间】:2023-04-04 04:00:01
【问题描述】:

Xcode 更新到 Beta 3 后,我无法点击 List 中的 NavigationLink。由于某种原因,该行是灰色的。

代码如下:

List {
        Section {

            NavigationLink(destination: Text("ProfileView")) {
                Text("Profil")
            }

            NavigationLink(destination: Text("Einstellungen")) {
                Text("Einstellungen und Datenschutz")
            }
        }
    }

【问题讨论】:

  • NavigationView 里面有这个吗?
  • 哦,对了,我没有那个。

标签: ios swift xcode navigation swiftui


【解决方案1】:

列表应该在 NavigationView 内,

如下所述更新您的代码,

NavigationView {
    List {
        Section {

            NavigationLink(destination: Text("ProfileView")) {
                Text("Profil")
            }

            NavigationLink(destination: Text("Einstellungen")) {
                Text("Einstellungen und Datenschutz")
            }
        }
    }
}

【讨论】:

    【解决方案2】:

    确保您的 NavigationLinkNavigationView

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-08
      • 2020-11-12
      • 2020-03-31
      • 2019-12-26
      • 2020-12-29
      • 1970-01-01
      相关资源
      最近更新 更多