ios - Cell of custom tableview using xib file, can not be clicked / selected / tapped -


i have tableview , customized cell using swift. below complete code:

class leftmenuviewcontroller: uiviewcontroller {      let titles: [string] = ["home", "category", "chat", "notification", "flagger", "feedback", "setting", "log out"]      override func viewdidload() {         super.viewdidload()          let leftmenuview : leftmenu = leftmenu()         let nib = uinib(nibname: "leftmenucell", bundle : nil)         leftmenuview.tablemenu.registernib(nib, forcellreuseidentifier: "cell")         leftmenuview.tablemenu.datasource = self         leftmenuview.tablemenu.delegate = self         leftmenuview.tablemenu.allowsselection = true         leftmenuview.tablemenu.backgroundcolor = uicolor.blackcolor()         self.view.addsubview(leftmenuview)     } }  extension leftmenuviewcontroller : uitableviewdelegate, uitableviewdatasource {     func tableview(tablemenu: uitableview, numberofrowsinsection section: int) -> int {         return titles.count     }      func numberofsectionsintableview(tableview: uitableview) -> int {         return 1     }      func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat {         return 40     }      func tableview(tableview: uitableview, diddeselectrowatindexpath indexpath: nsindexpath) {         tableview.deselectrowatindexpath(indexpath, animated: true)         print("clicked \(indexpath.row)")         switch indexpath.row {          case 0:             sidemenuviewcontroller?.contentviewcontroller = uinavigationcontroller(rootviewcontroller: homeviewcontroller())             sidemenuviewcontroller?.hidemenuviewcontroller()             break         case 1:             sidemenuviewcontroller?.contentviewcontroller = uinavigationcontroller(rootviewcontroller:categoryviewcontroller())             sidemenuviewcontroller?.hidemenuviewcontroller()             break         default:             break         }     }      func tableview(tablemenu: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell:leftmenucell = tablemenu.dequeuereusablecellwithidentifier("cell") as! leftmenucell         cell.backgroundcolor = uicolor.blackcolor()         cell.menuname.text = titles[indexpath.row]         cell.menuname.textcolor = uicolor.whitecolor()         return cell     } } 

but confused, cell can not clicked / tapped. thought needs simple diddeselectrowatindexpath implementation? if print inside method, not writing out "clicked".

so whats wrong in code, can me?

thanks

change diddeselectrowatindexpath didselectrowatindexpath.

  • didselect called when cell tapped.
  • diddeselect called on first cell when cell selected.

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -