Search code examples
iosuiscrollviewuicollectionview

Bypass UIScrollViewDelegate when scroll in UICollectionView


I have a UICollectionView which is a child view of a UIScrollView. Is it possible to bypass the UIScrollViewDelegate when there is a scroll inside the UICollectionView?


Solution

  • You can check in your UIScrollViewDelegate methods as like below and bypass your implementations inside that method.

    Example:

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
    
            guard scrollView != yourCollectionView else{
    
                return
            }
    
            //Your implementations goes here
        }