Manisha Sharma
Manisha Sharma

Reputation: 1

scroll all CollectionViewCell inside all tableviewcell

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

Answers (1)

Warren Burton
Warren Burton

Reputation: 17372

Both UICollectionView and UITableView are sub-classes of UIScrollView so you can do one of these things to manipulate the scroll:

  • set contentOffset on them or,
  • use 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:

  1. 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.

  2. Apply the detected change in content offset/position to all other collections in (visible) tableview cells.

Upvotes: 1

Related Questions