标题说明了一切。我想显示一个数组数组,数组2的每个索引都有多个行数组
如果您喜欢视觉效果,这就是它的样子
Section 1:
Section 1
Section 1
Cell
Section 2
Cell
Section 2
Section 1
Cell
Section 2
Cell
Section 2
Section 1
Section 1
Cell
Section 2
Cell
Section 2
Section 1
Cell
Section 2
Cell
Section 3
Section 1
Section 1
Cell
Section 2
Cell
Section 2
Section 1
Cell
Section 2
Cell
答案 0 :(得分:1)
UITableView没有内置支持,但您可以自己创建一些自定义标题和单元格。
基本上创建一个模型来支持结构:
let model = [[[a, b],[c,d]],[[e,f],[g,h]]]
您的numberOfSections
实施将返回model.map{$0.count}.reduce(0, +)
你的numberOfRowInSection
会做类似
let subSections = model[section]
var topLevelRow = indexPath.row
for subSection in subSections {
if topLevelRow < subSection.count {
print(subSection[topLevelRow])
break
} else {
topLevelRow -= subSection.count
}
}
createCellAtIndexPath
最后一部分是当该部分是顶部(subSection [0])时为其提供一个标题,如果不是则为另一部分提供。
本文中有一个关于如何进行多级表视图的好例子: http://sapandiwakar.in/nested-sections-in-uitableview/
答案 1 :(得分:1)
我认为这很容易,因为我们定义了Section表的数量可以使用func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
方法。
我们没有内置方法来定义该部分的节数。