Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift LazyVStack NavigationLink不可单击_Swift_Swiftui - Fatal编程技术网

Swift LazyVStack NavigationLink不可单击

Swift LazyVStack NavigationLink不可单击,swift,swiftui,Swift,Swiftui,我有一个懒洋洋的 ScrollView { if #available(iOS 14.0, *) { LazyVStack { ForEach(searchViewModel.allUsers, id: \.uid) { user in

我有一个懒洋洋的

                        ScrollView {
                            if #available(iOS 14.0, *) {
                                LazyVStack {
                                    ForEach(searchViewModel.allUsers, id: \.uid) { user in
                                        VStack {
                                            profileCard(profileURL: user.profileURL, username: user.username, age: user.age, cardWidth: self.cardWidth, country: user.city)
                                            NavigationLink(destination: ProfileDetailedView(userData: user)) {
                                                EmptyView()
                                            }.buttonStyle(PlainButtonStyle())
                                        }.padding(.top,5)
                                    }
                                }
                            } else {
                                // Fallback on earlier versions
                            }
                        }
现在
NavigationLink
不工作了

我没有LazyVStack的原始代码运行良好(如下)

更新


我正在视图顶部使用NavigationView

您在我的视图顶部使用NavigationView了吗? 例如:


是的,更新了我的答案。我正在视图的顶层使用NavigationView
                       List {
                            ForEach(searchViewModel.allUsers, id: \.uid) { user in
                                VStack {
                                    profileCard(profileURL: user.profileURL, username: user.username, age: user.age, cardWidth: self.cardWidth, country: user.city)
                                    NavigationLink(destination: ProfileDetailedView(userData: user)) {
                                        EmptyView()
                                    }.buttonStyle(PlainButtonStyle())
                                }.padding(.top,5)
                            }
                        }
NavigationView{ // -> Here
    List {
        ForEach(searchViewModel.allUsers, id: \.uid) { user in
            VStack {
                profileCard(profileURL: user.profileURL, username: user.username, age: user.age, cardWidth: self.cardWidth, country: user.city)
                NavigationLink(destination: ProfileDetailedView(userData: user)) {
                    EmptyView()
                }.buttonStyle(PlainButtonStyle())
            }.padding(.top,5)
        }
    }
}