Reputation: 11
I have the current structure: (-> indicates subview)
UIScrollView
(pageOne and pageTwo are subviews of UIScrollView. pageTwo contains a CollectionView)
I am trying to cancel scrolling of the parent UIScrollView if scrolls (drags) are detected within the collection. I did this by constructing a UIPanGestureRecognizer for pageTwo. While a drag is detected, I set:
UIScrollView.isScrollingEnabled = false
collection.isScrollingEnabled = true
When UIPanGestureRecognizer.State.ended (dragging in pageTwo stops), I set back
UIScrollView.isScrollingEnabled = true
collection.isScrollingEnabled = false
I have verified that the function correctly identifies dragging / ending dragging, but for some reason although dragging within pageTwo is correctly detected, the UIScrollView continues to scroll. More specifically, upon dragging in pageTwo and successfully changing UIScrollView scroll to false, and collection scroll to true, the initial tap causes the UIScrollView to scroll (page technically, since isPagingEnabled is true for ScrollView), back to the top of pageOne.
Any suggestions?
(Sorry if my formatting for this question is incorrect, first time posting)
Upvotes: 1
Views: 199
Reputation: 11
SOLVED
The issue I was specifically having had to do with
UIScrollView.isPagingEnabled = true
Upon setting isPagingEnabled to false and having collection.isScrollingEnabled always set to true (versus switching to false as stated above), the UI works as anticipated.
Upvotes: 0