如何循环 CollectionViewCell

How to loop the CollectionViewCell

我在 UICollectionView 中有一组 collectionviewcell,我正在使用函数 NSTimer.scheduledTimerWithTimeInterval 命令每个单元格每 4 秒显示一次并向左移动。目前,它们不在循环中,一旦最后一个单元格出现,它就会在屏幕上变成空白。我如何为这些细胞创建循环并使它们连续移动?请指教

func timeSlide() {

    var timeslide = NSTimer.scheduledTimerWithTimeInterval(4, target: self, selector: Selector("onTime"), userInfo: nil, repeats: true)
}

func onTime(){

    collection.contentOffset = CGPointMake(collection.contentOffset.x+375, 0)

}

您需要知道集合视图中有多少项,当它结束时您需要将 contentOffset 设置回开头。