Reputation: 1
I am creating a custom Tableviewcell having CollectionView inside it. When scrolling a CollectionView inside a tableview cell , I want the cells in other CollectionViews to get automatically scrolled.
How can I implement this ? the "parameters" and "unit" are UILabels inside Tableview cell, the "labels" are the uiLabels of "Collectioniew" inside UITableviewCell
Upvotes: 0
Views: 484
Reputation: 17372
Both UICollectionView
and UITableView
are sub-classes of UIScrollView
so you can do one of these things to manipulate the scroll:
contentOffset
on them or,func scrollToItem(at: IndexPath, at: UICollectionView.ScrollPosition, animated: Bool)
What you do depends on how you wish your UI to work.
Assuming each tableview cell contains a collection the basic technique will be:
When inner collection is scrolled by the user , you can detect this with the UIScrollViewDelegate
delegate method func scrollViewDidScroll(UIScrollView)
. There are other UIScrollViewDelegate
methods that will help here too.
Apply the detected change in content offset/position to all other collections in (visible) tableview cells.
Upvotes: 1