UICollectionView:如何定义支持水平和垂直滚动的UICollectionViewLayout? [英] UICollectionView: How to define a UICollectionViewLayout that supports horizontally and vertically scrolling?

查看:267
本文介绍了UICollectionView:如何定义支持水平和垂直滚动的UICollectionViewLayout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在尝试创建一个 UICollectionView ,这应该会显示一个简单的 excel-like-spreadsheet rows columns 。我认为这应该是一个简单的任务, UICollectionViews 。我真的想在 UICollectionView 中进行实现,而不是在任何网格框架中

At the moment I'm trying to create an UICollectionView, that should display a simple excel-like-spreadsheet, with rows and columns. This should be an easy task with UICollectionViews, I believed. And I really would like to do the implementation in UICollectionView, not in any grid framework.

但此刻我暂停了一下。我已经想到的是,遗憾的是我不能使用 UICollectionViewDelegateFlowLayout ,因为这只支持滚动 水平垂直方向。但我需要双向滚动

But at the moment I'm hanging a little bit. What I've figured out is, that I unfortunately can't use a UICollectionViewDelegateFlowLayout, because this only supports scrolling in either horizontally or vertically direction. But I need scrolling in both directions.

因此我必须使用 UICollectionViewLayout ,但为此我没有找到好的例子,如何使用它。你有没有一个例子,如何子类化 UICollectionViewLayout 来支持

提前致谢。

推荐答案

UICollectionViewFlowLayout 绝对不能 - 网格布局只能沿水平或垂直方向滚动一个轴。

UICollectionViewFlowLayout definitely can't - "The grid layout scrolls along one axis only, either horizontally or vertically."

它是 UICollectionViewLayout 的子类。好像你可以创建自己的 UICollectionViewLayout 的子类并向两个方向滚动。

It is a subclass of UICollectionViewLayout. Seems like you could create your own subclass of UICollectionViewLayout and scroll in both directions.

你是什么意思页面,你想像 scrollview 那样进行分页?我想知道在 UICollectionView 中使用UICollectionViewFlowLayout进行垂直滚动,在 UIScrollView 内进行水平滚动。

What do you mean by page, you want to do paging like a scrollview? I'm wondering about using UICollectionViewFlowLayout in a UICollectionView for vertical scrolling, inside a UIScrollView for horizontal scrolling.

这篇关于UICollectionView:如何定义支持水平和垂直滚动的UICollectionViewLayout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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