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 } }
try this: (add ':' in selector name)
friendscell.addfriendbutton.addtarget(self, action: "addbuttonpressed:", forcontrolevents: .touchupinside)
i hope solve problem of un recognised selector.
Comments
Post a Comment