📌  相关文章
📜  一段时间后在 ios swift 代码示例中自动移动到集合的 nect 单元

📅  最后修改于: 2022-03-11 15:01:01.179000             🧑  作者: Mango

代码示例1
/**
     Scroll to Next Cell
     */
    func scrollToNextCell(){

        //get Collection View Instance
        let collectionView:UICollectionView;

        //get cell size
        let cellSize = CGSizeMake(self.view.frame.width, self.view.frame.height);

        //get current content Offset of the Collection view
        let contentOffset = collectionView.contentOffset;

        //scroll to next cell
        collectionView.scrollRectToVisible(CGRectMake(contentOffset.x + cellSize.width, contentOffset.y, cellSize.width, cellSize.height), animated: true);


    }

    /**
     Invokes Timer to start Automatic Animation with repeat enabled
     */
    func startTimer() {

        let timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("scrollToNextCell"), userInfo: nil, repeats: true);


    }