2

I feel this should be simple to accomplish but for some reason im lost. I have a button that will scroll a UICollectionView so the cell at an given IndexPath is top of the screen. problem is that the method does not take into account the supplementary header view. so :

collectionView?.scrollToItem(at: indexP, at: UICollectionViewScrollPosition.top, animated: true)

actually means the cell disappears under the header. How best to resolve so that calling UICollectionViewScrollPosition.topscrolls to the top under the header?

in the viewDidLoad of my UICollectioViewController

let layout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout
        layout?.sectionHeadersPinToVisibleBounds = true 
RyanTCB
  • 7,400
  • 5
  • 42
  • 62
  • I used this solution: https://stackoverflow.com/questions/49638855/scrolltoitem-at-indexpath-at-top-hides-cell-under-header-when-sectionheaderspin/51250268#51250268 – Red Apr 17 '19 at 15:04

0 Answers0