2016-09-20 10 views
1

タイトルはすべてです。私は、配列の配列を表示すると、アレイ2の各インデックスは、これは視覚的なもののようなあなたUItableViewに複数のセクションを含めることは可能ですか?セクション1には2つのセクションがあり、これら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

IDTS可能です。 –

答えて

1

はのUITableViewは一切、このためのサポートが組み込まれていた場合、それがどのように見えるんだろうか行

の複数のアレイをされましたカスタムヘッダーとセルを使って自分で何かを作成することもできます。

基本的な構造をサポートするモデルを作成:

let model = [[[a, b],[c,d]],[[e,f],[g,h]]] 

あなたnumberOfSections実装が戻ってくるの

let subSections = model[section] 
var topLevelRow = indexPath.row 
for subSection in subSections { 
    if topLevelRow < subSection.count { 
     print(subSection[topLevelRow]) 
     break 
    } else { 
     topLevelRow -= subSection.count 
    } 
} 

同じ実装のようなものがのために使用することができるだろうmodel.map{$0.count}.reduce(0, +)

あなたnumberOfRowInSection the createCellAtIndexPath

最後の部分は、セクションがトップセクション(subSection [0])である場合に1つのヘッダーを提供し、そうでない場合に1つのヘッダーを提供することです。

それについて移動する方法については、この記事では、マルチレベルのテーブルビューの良い例があります: http://sapandiwakar.in/nested-sections-in-uitableview/

1

我々はfunc tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {を使用して持つことができ、セクションテーブルの数を定義するので、私はとてもその容易に可能ではないと思います方法。

セクションのセクション数を定義するための組み込みメソッドはありません。

関連する問題