.sheet scrollview 上的 .ontapgesture 不工作 swiftui
.sheet .ontapgesture on scrollview not working 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)})
因为我在 AuthorListElement 中有另一个 .onTapGesture。当我删除 AuthorListElement 中的那个时,它起作用了。
不幸的是,它不起作用。当我点击其中一个单元格时,它不会执行任何操作。我的 .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)})
因为我在 AuthorListElement 中有另一个 .onTapGesture。当我删除 AuthorListElement 中的那个时,它起作用了。