Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
列表后显示的Swift 3 UITableView部分_Swift_Uitableview_Swift3_Uitableviewsectionheader - Fatal编程技术网

列表后显示的Swift 3 UITableView部分

列表后显示的Swift 3 UITableView部分,swift,uitableview,swift3,uitableviewsectionheader,Swift,Uitableview,Swift3,Uitableviewsectionheader,我正在尝试使用swift 3 UITableViewController创建产品列表,但这些部分显示在产品列表之后。一定有什么东西我找不到了 下面是一个简化的代码 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) ->

我正在尝试使用swift 3 UITableViewController创建产品列表,但这些部分显示在产品列表之后。一定有什么东西我找不到了

下面是一个简化的代码

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)"
}

这是因为您使用了错误的回调

使用
override func tableView(\utableview:UITableView,titleForHeaderInSection:Int)->String?
而不是
override func tableView(\utableview:UITableView,titleforfootensection:Int)->String?


前者将文本作为标题放置在节上方。后者将其放在底部。

TitleForFooterInstition vs.TitleForHeaderInstitution谢谢@Vadian我怎么可能看不到这一点?非常感谢。