0
votes

Hy, i have a UICollectionViewController where scrolling in a vertical direction is possible. I have several sections, for instance, Movies, Books, Music, etc. And several items per section, Movie 1, Movie 2, Music 1, Music 2. I was able to split the different sections by creating Header. I used the example in How to Add Header and Footer View in UICollectionView, so my application is very similar to the one in that example.
Now what i wanted to do is, enabling horizontal scrolling in the several items per section, without scrolling the entire page. Or by other words, if i have one screen with the Section Movies and Music. If i scroll horizontal in the Movies section, i will see Movies 2, but Music 1. If i scroll again in Movies i will see Movies 2, but still Music 1. I've read that UICollectionView only permits one type of scrolling, either vertical or horizontal, and that lead me to UITableView, but searching on that topic i only found solutions that when you swipe horizontally all the sections move, and not only one.
Thank you in advance

EDIT:
Maybe i can use a UITableView and add a UIScrollView with the contentSize of the UITableView Cell, any ideas if that is a good way to go?

2

2 Answers

2
votes

I have done something similar as follows. But I didn't use scrollviews (directly) just UICollectionViews for sideways scrolling within UITableView for vertical scrolling.

Parent: UITableView :

  • Sections: Music, Movies
  • Rows per section - 1

Each row is then a UICollectionView that scrolls horizontally

  • Number of secitions: 1
  • Number of items in section: (Number of Movies/Music etc)

|----------------|
|Movies          |  < header for section in table
|----------------|
| M1  M2  M3  M4 | M5  M6 ....   < sideways scrolling collection of objects
|----------------|               < M5 & M6 are objects off screen (in essence)
|Music           |  < next section header
|----------------|
...etc              < another collection view
0
votes

So after some more browsing i found the answer on another post:

Use uicollectionview inside uitableviewcell
AFTabledCollectionView

Thank you @button for guiding me in the right direction.