ios - 创建一个 View ,如 iOS 的图片所示

标签 ios iphone uicollectionview

我正在创建一个应用程序,我需要以这种格式显示数据 Data representation

现在,这是一个 UITableView,假设它是一个 UITableViewCell。

我在想做什么:-

1. Lets create a UICollectionView inside the UITableViewCell, this will have 
   3 rows. Every row will contain another UICollectionView where I will put 
   the data
   FLow will be like this :-
   UITableView -> UITableViewCell -> UICollectionView -> UICollectionViewCell -> UICollectionView -> UICollectionViewCell

2. create a UICollectionView inside the UITableViewCell, this will have 
       3 rows. Now I will create a view which contains data as whole and put it on cell. Height will be calculated programatically and view is put inside UICollectionViewCell

所以其他解决方案也是如此,但我对我想到的解决方案不满意。

如果有人知道执行此操作的正确解决方案。让我知道。我更喜欢以更好的方式做事。

如果您需要更多详细信息,请告诉我

最佳答案

创建一个UICollectionViewUICollectionViewCell 添加到 Storyboard中的 View 将 Vertical UIStackView 添加到具有属性 Fill 和 Equal Spacing 的单元格。 将布局约束添加到单元格的 top,left,right,bottom

现在在 cellForRowAtIndexPath 函数中,您可以将尽可能多的 addArrangedSubviews 添加到 UIStackView

要自定义 Cell 的大小覆盖函数 sizeForItemAtIndexPath

关于ios - 创建一个 View ,如 iOS 的图片所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51606600/

相关文章:

objective-c - 编译器错误阻止 iOS 项目编译

Objective C 的 Javascript 语法荧光笔

javascript - 如何在 iPhone 上拖动 'div' 元素

ios - 逆时针 iOS CircleLayout

ios - 在旋转界面方向时将 contentOffset 保持在 UICollectionView 中

ios - 如何在点击时展开多个 Collection View Cell

iphone - ios如何在小视野范围内打开相机

ios - 如何从另一个 UIPopover Controller 打开 UIPopover Controller ?

ios - 将项目插入数组时基于更新 UIimage

iphone - 用于 ios 开发的 Windows 上的 Xcode