简体   繁体   English

iOS UICollectionView图库具有交叉滚动

[英]iOS UICollectionView Gallery with cross-scrolling

Hy, i have a UICollectionViewController where scrolling in a vertical direction is possible. 嗨,我有一个UICollectionViewController,可以在垂直方向上滚动。 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. 我有几个部分,例如电影,书籍,音乐等。每个部分有几个项目,电影1,电影2,音乐1,音乐2。我能够通过创建页眉来拆分不同的部分。 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. 我使用了如何在UICollectionView中添加页眉和页脚视图中的示例 ,因此我的应用程序与该示例中的应用程序非常相似。
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. 如果在“电影”部分中水平滚动,我将看到电影2,但音乐1。如果在电影中再次滚动,我将看到电影2,但音乐仍然为1。我已阅读到UICollectionView仅允许一种滚动方式,垂直或水平方向,这使我进入UITableView,但是在该主题上进行搜索时,我仅找到了以下解决方案:水平滑动时,所有部分都会移动,而不仅仅是一个。
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? 也许我可以使用UITableView并添加具有UITableView Cell的contentSize的UIScrollView,是否有一个好主意?

I have done something similar as follows. 我做了如下类似的事情。 But I didn't use scrollviews (directly) just UICollectionViews for sideways scrolling within UITableView for vertical scrolling. 但是我并没有(直接)使用scrollviews(直接使用)UICollectionViews在UITableView中进行横向滚动以进行垂直滚动。

Parent: UITableView : 父级:UITableView:

  • Sections: Music, Movies 板块:音乐,电影
  • Rows per section - 1 每节行数-1

Each row is then a UICollectionView that scrolls horizontally 然后,每一行都是一个UICollectionView,它可以水平滚动

  • Number of secitions: 1 分割数: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

So after some more browsing i found the answer on another post: 因此,在进行更多浏览之后,我在另一篇文章中找到了答案:

Use uicollectionview inside uitableviewcell 在uitableviewcell内使用uicollectionview
AFTabledCollectionView AFTabledCollectionView

Thank you @button for guiding me in the right direction. 感谢@button引导我朝正确的方向发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM