2017-05-06 10 views
0

swift 3 UITableViewControllerを使用して製品のリストを作成しようとしていますが、セクションが製品のリストの後に表示されています。私が欠けている何かがあるに違いありません、ここではどこでもSwift 3リストの後に表示されるUITableViewセクション

を見つけることができなかった単純化されたコードは間違ったコールバックを使用しているので、それがある

let data = [["0,0", "0,1", "0,2"], ["1,0", "1,1", "1,2"], ["2,0", "2,1", "2,2"], ["3,0", "3,1", "3,2"]] 

override func numberOfSections(in tableView: UITableView) -> Int { 
    return data.count//productCategoriesSections.count 
} 

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return data[section].count//productCategories[section].count 
} 


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: "defaultCategoryCell", for: indexPath) as! CategoryDefaultTableViewCell 
    cell.titleTextView.text = data[indexPath.section][indexPath.row] 
    return cell 
} 

override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { 
    return "Section \(section)" 
} 

screenshot

+1

* title For **フッター** InSection *対* titleFor **ヘッダー** InSection * – vadian

+0

@vadian – ericknmp

答えて

0

です。

override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String?の代わりにoverride func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?を使用してください。

前者は、テキストをセクションの上にヘッダーとして配置します。後者は、それを底に置く。

+0

ありがとうございました。ありがとうございました – ericknmp

関連する問題