Reputation: 82
I have an array with unknown amount of items in it and I need to scroll them horizontaly with one item per page. Basicly, I want smt like this (for some reaons this project doesn't work for me).
So, the obvious solution would be to create CollectionView
inside TableViewCell
, but the questions are:
First, how can I leaf them over like in the example above? CollectionViewCells
move smoothly like a scrollView
, but I need to "swap" between them.
Second, how to display one cell per page? And should I even pick CollectionView
approach? Because I can not find anything like this in the internet.
I would appreciate any help. Thank you!
Upvotes: 1
Views: 119
Reputation: 2513
So, you can make each collection view cell the same size as the whole application screen. Then set these attributes to your UICollectionView:
...
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpasing = 0
let yourCollectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
yourCollectionView.pagingEnabled = true
.....
The example is in this video. https://www.youtube.com/watch?v=kecV6xPTTr8&index=1&t=1s&list=PL0dzCUj1L5JHfozquTVhV4HRy-1A_aXlv
Upvotes: 3