我正在尝试在 SwiftUI 中重新创建许多社交媒体应用程序中看到的帐户关注者流程。
\n步骤 3 和 4 可以永远继续下去(下面是另一个例子):
\nMyProfile -> Followers (my followers list) -> FollowerView -> Followers (their followers list) -> FollowerView -> Followers (their followers list) -> FollowerView and so on...\nRun Code Online (Sandbox Code Playgroud)\n然而,通过运行下面的实现,XCode 控制台会打印:
\n\n\n\xe2\x80\x9cmyApp.SomeProfile\xe2\x80\x9d 的 navigationDestination 已在堆栈的较早位置声明。仅使用最接近堆栈根视图声明的目标。
\n
我知道为什么会这样,但不确定如何解决这个问题。我也认为用作值的类型是否NavigationLink合适,因为它是Int。将其替换为更自定义的类型会更好吗?
任何帮助将不胜感激。
\n// Enum with custom options\nenum ViewOptions: Hashable {\n case followers(Int)\n \n @ViewBuilder func view(_ path: Binding<NavigationPath>, …Run Code Online (Sandbox Code Playgroud) ios swift swiftui swiftui-navigationlink swiftui-navigationstack