UICollectionView的每个部分都独立滚动? [英] Independent scrolling for each section of a UICollectionView?

查看:77
本文介绍了UICollectionView的每个部分都独立滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 UICollectionView 来构建一个布局,其中每个部分可以独立滚动?例如,想象20行图像,其中每行可以水平独立滚动以在屏幕外显示更多图像(在此过程中不滚动其他行);并且可以垂直滚动整个视图以显示更多行。

Is it possible to use UICollectionView to build a layout where each section can be independently scrolled? For example, imagine 20 rows of images, where each row could be scrolled independently horizontally to reveal more images offscreen (without scrolling other rows in the process); and the entire view could be scrolled vertically to reveal more rows.

我相信这样的事情可以用UIScrollView中的几个UICollectionView实例来实现;但是,利用UICollectionView插入/移动部分会很棒。

I believe something like this could be implemented with several instances of UICollectionView inside a UIScrollView; however, it'd be great to leverage UICollectionView for inserting/moving sections.

我怀疑这是不实际的,因为UICollectionView是UIScrollView的子类;但也许这可以使用自定义UICollectionViewLayout来完成?

I suspect this isn't practical since UICollectionView is a subclass of UIScrollView; but perhaps this can be done with a custom UICollectionViewLayout?

推荐答案

您可以在表格单元格中放置多个UICollectionView。桌子垂直滚动。可以将集合视图配置为水平滚动。我在复杂的布局上这样做,效果很好。需要考虑的一个限制是,制作需要从一个表格单元格移动到另一个表格单元格的动画要困难得多,并且您无法使用整齐的单一集合更改集合视图布局来为表格视图中的所有项目设置动画。但如果这些约束不是问题,那么这是一个相对简单的解决方案。

You can put multiple UICollectionViews in table cells. The table scrolls vertically. The collection views can be configured to scroll horizontally. I'm doing this on a complex layout and it works well. One constraint to consider is it is much more difficult to do animations that need to move from one table cell to another and you can't use a neat single change of collection view layout to animate all the items in your table view. But if these constraints aren't a problem then this is a relatively easy solution.

这篇关于UICollectionView的每个部分都独立滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆