Search code examples
uiscrollviewgesture

.sheet .ontapgesture on scrollview not working swiftui


Unfortunately, it does not work. When I tap one of the cells it does not do anything. My .sheet is outside of 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)})

Solution

  • Because I had another .onTapGesture inside the AuthorListElement. When I deleted the one in the AuthorListElement it works.