我有一台LazyVStack
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的原始代码运行良好(如下所示)
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
发布于 2021-04-13 20:45:01
你在我的视图顶部用过NavigationView吗?示例:
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)
}
}
}https://stackoverflow.com/questions/67073014
复制相似问题