I want my collectionView to start from the first one and 3 seconds later automatically scroll to the second one and 3 seconds later to the 3rd one and so on... How can i do this? The code below works but for only 1 time. It scrolls from the first one to the second one but then it stops.
func scrollToNextCell(){
let cellSize = CGSize(width: self.view.frame.width, height: self.view.frame.height)
let contentOffset = myCollectionView.contentOffset;
myCollectionView.scrollRectToVisible(CGRect(x: contentOffset.x + cellSize.width, y: contentOffset.y, width: cellSize.width, height: cellSize.height), animated: true)
}
func startTimer() {
_ = Timer.scheduledTimer(timeInterval: 3.0,
target: self,
selector: #selector(scrollToNextCell),
userInfo: nil,
repeats: false)
}