UICollectionView 水平分页 - 我可以使用流布局吗? [英] UICollectionView horizontal paging - can I use Flow Layout?

查看:22
本文介绍了UICollectionView 水平分页 - 我可以使用流布局吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与 使用流布局或自定义?.

这是我正在尝试做的一个示例:

Here is an illustration of what I’m trying to do:

我想知道我是否可以使用 UICollectionViewFlowLayout 及其子类来做到这一点,或者我是否需要创建一个完全自定义的布局?根据 UICollectionView 上的 WWDC 2012 视频,如果您使用带有垂直滚动的 Flow Layout,您的布局线是水平的,如果您水平滚动,您的布局线是垂直的.我想要水平滚动的集合视图中的水平布局线.

I’m wondering if I can do this with a UICollectionViewFlowLayout, a subclass thereof, or if I need to create a completely custom layout? Based on the WWDC 2012 videos on UICollectionView, it appears that if you use Flow Layout with vertical scrolling, your layout lines are horizontal, and if you scroll horizontally, your layout lines are vertical. I want horizontal layout lines in a horizontally-scrolling collection view.

我的模型中也没有任何固有部分 - 这只是一组项目.我可以将它们分组为部分,但集合视图是可调整大小的,因此页面上可以容纳的项目数量有时会发生变化,似乎每个项目所在页面的选择最好留给布局而不是如果我没有任何有意义的部分,请使用模型.

I also don’t have any inherent sections in my model - this is just a single set of items. I could group them into sections, but the collection view is resizable, so the number of items that can fit on a page would change sometimes, and it seems like the choice of which page each item goes on is better left to the layout than to the model if I don’t have any meaningful sections.

那么,我可以使用 Flow Layout 来做到这一点,还是需要创建自定义布局?

So, can I do this with Flow Layout, or do I need to create a custom layout?

推荐答案

你是对的 - 这不是股票水平滚动集合视图布局单元格的方式.恐怕您将不得不实现自己的自定义 UICollectionViewLayout 子类.要么,要么将您的模型分成几个部分.

You're right – that's not how a stock horizontally-scrolling collection view lays out cells. I'm afraid that you're going to have to implement your own custom UICollectionViewLayout subclass. Either that, or separate your models into sections.

这篇关于UICollectionView 水平分页 - 我可以使用流布局吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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