【问题标题】:How to set content of UIColletionView cell vertically?如何垂直设置集合视图单元格的内容?
【发布时间】:2016-06-29 07:41:27
【问题描述】:

我在 UICollectionViewCell 内的 UITableView 中设置我的 json 数据

但我得到的数据是

-----------   -----------  ----------
|  Data 1 |   | Data 2  |  | Data 3 |
|         |   |         |  |        |
-----------   -----------  ----------
-----------   -----------  ----------
|  Data 4 |   | Data 5  |  | Data 6 |
|         |   |         |  |        |
-----------   -----------  ----------

但我希望我的数据这样显示(表示垂直)-

-----------   -----------  ----------
|  Data 1 |   | Data 3  |  | Data 5 |
|         |   |         |  |        |
-----------   -----------  ----------
-----------   -----------  ----------
|  Data 2 |   | Data 4  |  | Data 6 |
|         |   |         |  |        |
-----------   -----------  ----------

我将每个 Indexpath.row 中的数据数组从 CollectionView cellForRowAtIndexPath 传递到 TableView cellForRowAtIndexPathTableView cellForRowAtIndexPath,我正在打印我在上面提取到每个 Indexpath.row 的数据。

【问题讨论】:

  • 集合是否只有 4 个单元格?
  • 不,CollectionView 有 28 个单元格(作为 4 行和 7 列),就像一个 TIMETABLE。 @BharatModi
  • 你能不能展示一些图片,你需要做什么?正如您所说,您的 collectionView 单元格具有 tableView,知道您到底想要做什么有点令人困惑?
  • 设置scrollDirection水平
  • 通过应用自定义布局?

标签: ios objective-c uitableview uicollectionview nsarray


【解决方案1】:

使用名为ScrollDirectionUICollectionView 的属性。我认为它应该改变滚动方向(显然),从而改变单元格的布局方式。当您选择了 collectionview 时,您也可以在 Attributes Inspector 的情节提要中找到它。

虽然这样做只会强制collectionview按照你想要的方式布局单元格,但你仍然需要做一些工作来强制4行/7列。

【讨论】:

    【解决方案2】:

    你只需要设置collection view的滚动方向-

    以编程方式 -

    Your_Collection.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    

    通过故事板或 xib 文件 -

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 1970-01-01
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多