swift - Sections in tableView not showing -


i have constructed code below, 'section 1' header plus elements appearing. expect 3 headers appear corresponding elements underneath, why not happening?

import foundation import uikit    class summary: uiviewcontroller, uitableviewdelegate, uitableviewdatasource  {       var itemsinsections: array<array<string>> = [["1a", "1b", "1c"], ["2a", "2b"], ["3a", "3b", "3c", "3d", "3e"]]     var sections: array<string> = ["section 1", "section 2", "section 3"]        @iboutlet var tableview: uitableview!        func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell {          let cell:tableviewcell1 = self.tableview.dequeuereusablecell(withidentifier: "cell") as! tableviewcell1           cell.label.text = "\(itemsinsections[indexpath.section][indexpath.row])"         return cell     }         override func viewdidload() {         let nib = uinib(nibname: "tblcell", bundle: nil)         tableview.register(nib, forcellreuseidentifier: "cell")          self.tableview.datasource = self         self.tableview.delegate = self      }      func numberofsectionsintableview(tableview: uitableview) -> int {         return self.sections.count     }      func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {         return self.itemsinsections[section].count     }      func tableview(_ tableview: uitableview, titleforheaderinsection section: int) -> string? {         return self.sections[section]     }      } 

the method numberofsection signature is:

optional func numberofsections(in tableview: uitableview) -> int 

if not set (since yours didn't match signature), should return 1 section default. that's why seeing 1 section. confirmed you, version wasn't called.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -