简体   繁体   English

在iOS上创建多列视图

[英]Creating a multi-column view on iOS

I just got a design handed to me for implementation. 我刚刚有一个设计交给我实施。 At the moment this view should list elements vertically in two columns (I imagine that this would translate to more columns on the upcoming design for iPad), all of which with a maximum width equal to that of the column width but different heights (determined by the ratio of the image). 目前,这个视图应该在两列中垂直列出元素(我想这将转化为即将推出的iPad设计中的更多列),所有这些列的最大宽度等于列宽但不同的高度(由图像的比例)。 As the user scrolls down more items should be added to the flow, most probably to alternating columns. 当用户向下滚动时,应该将更多项添加到流中,最可能是交替列。 Ie I need to determine the height of the object/cell and then determine which column to add this to. 即我需要确定对象/单元格的高度,然后确定要将其添加到哪个列。 Also the items should be able to handle clicks. 此外,这些项目应该能够处理点击次数。

申请流程

My first thought was UITableView, then UIScrollView and lastly UICollectionView (I haven't worked with UICollectionView before). 我的第一个想法是UITableView,然后是UIScrollView,最后是UICollectionView(我之前没有使用过UICollectionView)。

How would you go about this? 你会怎么做?

UICollectionView is the way to go, for sure. UICollectionViewUICollectionView是要走的路。

Take a look at this layout . 看看这个布局

Your last choice is the best -> UICollectionView. 你最后的选择是最好的 - > UICollectionView。 You can define a custom layout. 您可以定义自定义布局。

Take a look on this: https://github.com/chiahsien/CHTCollectionViewWaterfallLayout 看看这个: https//github.com/chiahsien/CHTCollectionViewWaterfallLayout

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

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