简体   繁体   English

集合视图分页单元偏离中心

[英]collection view paging cell off center

I enabled paging via interface builder and when I scroll (I am using horizontal scrolling) it doesn't center the collection cell, instead as I progress it starts to end half in the screen. 我通过界面构建​​器启用了分页,当我滚动(我正在使用水平滚动)时,它不会使收集单元居中,而是随着我的前进,它开始在屏幕的一半结束。

I only have one giant cell displayed at a time. 一次只显示一个巨型单元格。

Any suggestions as to how I can tell the page to center the cell on the screen? 关于如何告诉页面将单元格在屏幕上居中的任何建议?

Thanks 谢谢

Make small change on collectionView size and flowLayout: 对collectionView的大小和flowLayout进行小的更改:

If you need section Insets: set left = right (if not set All = 0) 如果需要“插图插入”部分:设置左=右(如果未设置全部= 0)

MinimumLineSpacing always = 0; MinimumLineSpacing始终为0;

CollectionViewSize = CellSize and collectionView.center = self.view.center. CollectionViewSize = CellSize,collectionView.center = self.view.center。

Sample: https://github.com/lequysang/github_zip/blob/master/CollectionViewImagesCenterCell.zip 范例: https//github.com/lequysang/github_zip/blob/master/CollectionViewImagesCenterCell.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM