ios - How to add custom UIButton in table view cell? -


i have custom uibutton need add dynamic table view cell. none of tutorials i've used has worked me. uibutton appears when cell clicked, vanishes. when click button app crashes , ...viewcontroller addbuttonpressed]: unrecognized selector sent instance. need here?

class tableviewcell: uitableviewcell {          @iboutlet weak var addfriendbutton: uibutton!  }  class viewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource {      @ibaction func addbuttonpressed(sender: uibutton!) {             println("hey")     }      func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {              var friendscell = tableview.dequeuereusablecellwithidentifier("addfriendscell", forindexpath: indexpath) as! tableviewcell              friendscell.addfriendbutton.tag = indexpath.row              friendscell.addfriendbutton.addtarget(self, action: "addbuttonpressed", forcontrolevents: .touchupinside)              return friendscell          } } 

enter image description here

try this: (add ':' in selector name)

friendscell.addfriendbutton.addtarget(self, action: "addbuttonpressed:", forcontrolevents: .touchupinside) 

i hope solve problem of un recognised selector.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -