I've got a UICollectionView and a UITableView on the same controller. For reasons, I also need to implement some scrollView delegate methods. How can I distinguish which component is triggering the delegate ( e.g is it the table or the UICollectionView? )
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
//need to distinguish which component
//triggered the delegate here
snapToNearestCell(collectionView)
}
An idea is to add a tag to the UIScrollView for each component ( even though the scroll view isn't so straightforward to access and you need to iterate over the components views)
Any other ideas, best practices?
The table view and the collection view are the scroll view that's passed into that method. Set tags to the table view and the collection view and you are able to reason about who called that delegate method.