首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法单击LazyVStack NavigationLink

无法单击LazyVStack NavigationLink
EN

Stack Overflow用户
提问于 2021-04-13 18:20:41
回答 1查看 150关注 0票数 0

我有一台LazyVStack

代码语言:javascript
复制
                        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的原始代码运行良好(如下所示)

代码语言:javascript
复制
                       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

EN

回答 1

Stack Overflow用户

发布于 2021-04-13 20:45:01

你在我的视图顶部用过NavigationView吗?示例:

代码语言:javascript
复制
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)
        }
    }
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67073014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档