我的 Xcode 版本为 12,部署至 iOS 14.0。
- 我的主屏幕拥有 NavigationView
- 在 NavigationView 中有一个 TabView(包含 4 个选项卡)
- 每个选项卡中都有包含按钮和 NavigationLinks 的子视图
应用程序的导航功能正常运行(当我点击子视图中的 NavigationLink 时,它会导航到正确的视图,当我点击返回按钮时,它会关闭该视图。)但是,当我点击返回按钮时,控制台会打印以下错误:
Trying to pop to a missing destination at /Library/Caches/com.apple.xbs/Sources/Monoceros/Monoceros-103/Shared/NavigationBridge_PhoneTV.swift:337
除了错误日志之外,应用程序功能正常,所以我计划现在忽略这个错误... 但是我想知道它的意思是什么?我的代码中没有任何名为“Monoceros”的内容。我猜测这与TabView是NavigationView的子视图有关?
编辑:
几个月后,这个问题仍然存在。下面是可重现的代码。打开ContentView(),在FirstScreen()上点击NavigationView,然后点击返回按钮。它会打印出Monoceros lol。
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
FirstScreen()
.tabItem {
Text("One")
Image(systemName: "house.fill")
}
Text("Second Screen")
.tabItem {
Text("Two")
Image(systemName: "heart.fill")
}
}
}
}
}
struct FirstScreen: View {
var body: some View {
NavigationLink("Click here", destination: Text("Final Screen"))
// Click the back button on FinalScreen prints:
//Trying to pop to a missing destination at /Library/Caches/com.apple.xbs/Sources/Monoceros_Sim/Monoceros-120/Shared/NavigationBridge_PhoneTV.swift:341
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}