0
votes

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

1
Please share your code for better explanation.emrcftci
use scrollViewDidScroll to detect scrollingmutAnT

1 Answers

1
votes

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.