ios - tableview cell not clicking -


uitableviewcell sub class:

class menudrawertableviewcell: uitableviewcell {   @iboutlet weak var label3: uilabel! @iboutlet weak var image30: uiimageview!  override func awakefromnib() {     super.awakefromnib()     // initialization code } override func setselected(_ selected: bool, animated: bool) {     super.setselected(selected, animated: animated)     // configure view selected state }} 

i have class, got viewcontroller has table.

class openmenu: uiviewcontroller, uitableviewdelegate, uitableviewdatasource  {  @iboutlet weak var tablev: uitableview! @iboutlet weak var label1: uilabel! @iboutlet weak var label2: uilabel! var selected = 0 override func prepare(for segue: uistoryboardsegue, sender: any?) {     print("prepare")     var destvc  = segue.destination as! checkincontroller     var indexpath: nsindexpath = self.tablev.indexpathforselectedrow! nsindexpath     let menuitem = menulist[indexpath.row]     destvc.varview =  menuitem.index       } let newswiftcolor = uicolor(red: cgfloat(255), green: cgfloat(0), blue: cgfloat(238), alpha: cgfloat(1)) var menulist = [menu]()    func loadmenu() {     let photo1 = uiimage(named: "checkin")!     let menu1 = menu(name: "check in", photo: photo1, index: 20)!     let photo2 = uiimage(named: "checkin")!     let menu2 = menu(name: "add store", photo: photo2, index: 10)!     menulist += [menu1, menu2] } func numberofsectionsintableview(tableview: uitableview) -> int {     return 1 } func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int { return menulist.count // number of cell here } func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell {           let cellidentifier = "menudrawertableviewcell"     let cell = tableview.dequeuereusablecell(withidentifier: cellidentifier, for: indexpath indexpath) as! menudrawertableviewcell           let menuitem = menulist[indexpath.row]             cell.image30.image =  menuitem.photo     cell.label3.text = menuitem.name     cell.label3.numberoflines = 1;             if(0 == selected)     {         selected = 1         self.tablev.selectrow(at: indexpath, animated: true, scrollposition: uitableviewscrollposition.none)     }            return cell } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: indexpath) {     // cell selected code here      print("cell selected")      print(indexpath)     } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecell(withidentifier: "menudrawertableviewcell", for: indexpath indexpath) uitableviewcell             return cell }    @iboutlet weak var open: uibarbuttonitem! override func viewdidload() {     super.viewdidload()    loadmenu()     self.tablev.delegate = self     self.tablev.datasource = self     let size:cgfloat = 35.0 // 35.0 chosen arbitrarily     let preferences = userdefaults.standard     let name1 = ""+preferences.string(forkey: "name")!     label2.text = name1     label1.text = string(name1[name1.startindex])     label2.textcolor = uicolor.white     label1.textcolor = uicolor.white     label1.textalignment = nstextalignment.center     label1.font = uifont.systemfont(ofsize: 17)     label1.bounds =  cgrect(origin: cgpoint(x: 0,y :0), size: cgsize(width: size, height: size))     label1.layer.cornerradius = size / 2     label1.layer.borderwidth = 3.0     label1.layer.backgroundcolor = newswiftcolor.cgcolor     label1.layer.bordercolor = uicolor.black.cgcolor         } override func viewdidappear(_ animated: bool) { } override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }} 

what want, detect click on tableview. not able detect .i supposedly should cell selected printed, getting nothing.why click function not getting called?

you can check code have implemented 2 time methods(cellforrowatindexpath , cellforrowat)

 func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { }     func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell {  } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -