首页 > 解决方案 > 滚动视图上的.sheet .ontapgesture 不工作swiftui

问题描述

不幸的是,它不起作用。当我点击其中一个单元格时,它什么也不做。我.sheet在外面ScrollView

ScrollView(.vertical, showsIndicators: true) {
    VStack(spacing: 0) {
        ForEach(service.authorPost, id: \.author_id) { post in
            AuthorListElementView(authorPost: post)
                .onTapGesture {
                    self.shown.toggle()
                    self.selectedAuthor = post
                }
                                    .onAppear {
                                        self.service.loadMoreContentIfNeeded(currentItem: post)
                                    }
        }
    }
                            if service.isLoadingPage {
                                ProgressView()
                                    .padding()
                                    .offset(x: UIScreen.main.bounds.width / 3)
                            }
}
.sheet(isPresented: self.$shown, content: { PopupAuthorView(authorPost: selectedAuthor)})

标签: uiscrollviewgesture

解决方案


因为我在 AuthorListElement 中有另一个 .onTapGesture。当我删除 AuthorListElement 中的那个时,它起作用了。


推荐阅读