Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

ios - UICollectionView using sections leaves a gap between cells

I'm using a UICollectionView to show several sections of data. These sections have a fixed number of items. I want all the items to show in a continuous grid.

Right now I accomplish this in horizontal orientation: enter image description here

But in vertical this leaves a big gap: enter image description here

I want to solve this gap between sections because it's ugly and it doesn't belong there. I'd be happy to use a custom FlowLayout, but I can't find a tutorial that points me in the right direction (I've found several, but none of them really touch this problem specifically.)

Can anybody help me solve this problem, or at least point me in the right direction?

P.S: I've implemented sections because I'm loading the data on the fly. Using 1 section isn't an option for me at this moment.

UPDATE On request I'm adding the values used for my current FlowLayout. I'm using the standard Horizontal Flow Layout on a fullscreen (minus UINavigationBar) UICollectionView with 21 items per section.

  • Scroll direction: Horizontal
  • Cell size: 248, 196
  • Header / footer size: none
  • Min spacing for cells: 10
  • Min spacing for lines: 10
  • Section Insets: 20, 20, 10, 10
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use like this

It will solve Gap problem

UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];

layout.minimumInteritemSpacing = 0;
layout.minimumLineSpacing = 2;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...