ios - tableView cellForRowAtIndexPath method not getting called -


func tableview(tableview: uitableview, cellforrowatindexpath indexpath:   nsindexpath) -> uitableviewcell {     print("wtf getting hit...")      let cell = tableview.dequeuereusablecellwithidentifier("cell") as! uitableviewcell      cell.textlabel?.text = self.funlists[indexpath.row]      print("this better getting hit")       return cell; } 

for reason method isn't getting called.

i have set following

    uitableview.delegate=self     uitableview.datasource=self     uitableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell") 

and have included,

class viewuniversitylist: uiviewcontroller, uitableviewdelegate, uitableviewdatasource { 

there might several reason this. of them :

  • if using tableview in viewcontroller file, should add uitableviewdelegate , uitableviewdelegate delegates, :

    class viewcontroller: uiviewcontroller,uitableviewdelegate, uitableviewdelegate { ... } 
  • if have created tableview in code should following :

    tableview.delegate = self tableview.datasource = self tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "reuseidentifier") 
  • if that's done, or have create uitableview through storyboard separate class subclass of uitableview, definitely need define following methods :

    func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {...} 

~ func numberofsectionsintableview(tableview: uitableview) -> int {...} optional suggested @rmaddy, it's practice define it.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -