We have a collection view. I have made a calendar which shows dates horizontally & I scroll dates horizontally. Now on screen I see only 3-4 dates. Now I want to auto scroll to a particular selected date when calendar screen I shown.So the date I want to scroll to is not visible yet.
For that I got the indexpath for particular cell. Now I am trying to scroll it to particular indexpath.
func scrollCollectionView(indexpath:IndexPath)
{
// collectionView.scrollToItem(at: indexpath, at: .left, animated: true)
//collectionView.selectItem(at: indexpath, animated: true, scrollPosition: .left)
collectionView.scrollToItem(at: indexpath, at: .centeredHorizontally, animated: true)
_ = collectionView.dequeueReusableCell(withReuseIdentifier: "DayCell", for: indexpath) as? DayCell
}
Please tell how can I implement it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…