1

I have a UICollectionView, called parentCollectionView, and it scrolls horizontally. Inside each parentCollectionView's cell, is another UICollectionView, called childCollectionView, which scrolls vertically. In addition, parentCollectionView is set to paging (pagingEnabled = true).

Thus, you can scroll left/right to the next parentCollectionView, and you can scroll up/down in the childCollectionView.

There is an issue, however, regarding conflicting gestures. On the first horizontal swipe, the childCollectionView scrolling gesture is recognized. It fails to swipe horizontally, and doesnt scroll down in the child collectionview. But on the second swipe horizontally, it will page to the next horizontal cell as so.

How do I prevent the child collectionview from registering the first horizontal swipe? When I set isScrollEnabled = false on the childCollectionView, it fixes the issue, but I still would like to scroll down in my child collectionViews.

Is this something that is accomplished via gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:? Ive tried subclassing the scrollView the top answer in this stack overflow question, but was unsuccessful.

Cheers

Community
  • 1
  • 1
Josh O'Connor
  • 4,694
  • 7
  • 54
  • 98

1 Answers1

0

It appears as the problem was that the childCollectionView's content size was larger than the frame. Thus, the childCollectionView was given the impression that it was scrolling right within the childCV. I made sure the content size was identical to the CV frames.

//In my case, the childCV's width is exactly UIScreen.main.bounds.width - 30 
let scrollSize = CGSize(width: UIScreen.main.bounds.width - 30, height: self.listCollectionView.contentSize.height)

listCollectionView.contentSize = scrollSize
Josh O'Connor
  • 4,694
  • 7
  • 54
  • 98