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)
}
}
}