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

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

问题描述

这与使用流程布局或自定义有关但不同?

以下是我正在尝试做的事情的说明:

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水平分页 - 我可以使用Flow Layout吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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