UICollectionView: How to define a UICollectionViewLayout that supports horizontally and vertically scrolling?

AxM picture AxM · Nov 7, 2012 · Viewed 25.8k times · Source

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.

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.

Therefore I have to use a UICollectionViewLayout, but for this I didn't find good examples, how to use it. Has anyone of you an example, how to subclass an UICollectionViewLayout to support rows and columns?

Thanks in advance.

Answer

user1805608 picture user1805608 · Nov 7, 2012

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

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

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.