Swiftui 无法使用NavigationLink?

Swiftui 无法使用NavigationLink?,swiftui,Swiftui,我无法使用NavigationLink(目标:文本(“转到主页”),标签:{} 这是菜单栏,我想在向下或向上滚动时冻结此菜单栏 非常感谢您的视图是否包装在NavigationView中?您能否以我们可以测试的方式共享您正在使用的完整SwiftUI视图?您必须更新您的问题以使社区更清楚地帮助您。非常感谢!!!如果有效,您能接受上面的答案吗? NavigationView { ScrollView{ .navigationTitle(&q

我无法使用NavigationLink(目标:文本(“转到主页”),标签:{}

这是菜单栏,我想在向下或向上滚动时冻结此菜单栏


非常感谢

您的视图是否包装在NavigationView中?您能否以我们可以测试的方式共享您正在使用的完整SwiftUI视图?您必须更新您的问题以使社区更清楚地帮助您。非常感谢!!!如果有效,您能接受上面的答案吗?
    NavigationView {
          ScrollView{
                 .navigationTitle("Home")
                 .toolbar {
                     ToolbarItemGroup(placement: .bottomBar) {
                                VStack{
                                    HStack{
                                        NavigationLink(
                                            destination: Home(),
                                            label: {
                                                Image(systemName: "house")
                                                    .resizable()
                                                    .frame(width: 25.0, height: 20.0)
                                                    .foregroundColor(.blue)
                                                    .padding()
                                            })
       }
    }
                                  
import SwiftUI
struct HomeNav: View {
    @State var isActiveHome: Bool = false
    var body: some View {
        NavigationView {
            ScrollView{
                Text("Main")
                NavigationLink(
                    destination: Text("Home").navigationTitle("Home"),
                    isActive: $isActiveHome,
                    label: {
                        Image(systemName: "house")
                            .resizable()
                            .frame(width: 25.0, height: 20.0)
                            .foregroundColor(.blue)
                            .padding()
                    }).hidden().frame(width: 0, height: 0, alignment: .center)
                    .navigationTitle("Main")
                    .toolbar {
                        ToolbarItemGroup(placement: .bottomBar) {
                            VStack{
                                HStack{
                                    Button(action: {
                                        isActiveHome = true
                                    }, label: {
                                        Image(systemName: "house")
                                            .resizable()
                                            .frame(width: 25.0, height: 20.0)
                                            .foregroundColor(.blue)
                                            .padding()
                                    })
                                }
                            }
                            
                        }
                    }
            }
        }
    }
}