Swift: infinite pages in UiCollectionView
<p>I am playing with amazing project found on Git : <a href="https://github.com/ink-spot/UPCarouselFlowLayout" rel="nofollow">https://github.com/ink-spot/UPCarouselFlowLayout</a></p>

<p>I am trying to create an infinite carousel. Meaning it will start from the first item after the last one. </p>

<p>I was trying to amend collectionView - cellForItemAtIndexPath method with code: </p>

<pre><code>func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {

    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(CarouselCollectionViewCell.identifier, forIndexPath: indexPath) as! CarouselCollectionViewCell
    let character = items[indexPath.row]
    cell.image.image = UIImage(named: character.imageName)


    if indexPath.row == items.count - 2 {

        items.insert(items[0], atIndex: items.count)
        items.removeAtIndex(0)


        //self.collectionView.reloadItemsAtIndexPaths([NSIndexPath(forItem: 0, inSection: 0)])
        self.collectionView.reloadData()
    }

    return cell
}
</code></pre>

<p>My idea was to update source array moving first element to the end. But it is not working. </p>

<p>Also I have a question, how can I amend code to see 2nd element in the center after program loads? So that It would show 2nd element and will have 1st on the left and third on the right.</p>

<p>thanks!</p>