ios - Trouble changing UIButton image -


i have tableview in post users feeds , added heart button in cell view. created class cell view , declared @iboutlet of button there. in cellforrowatindexpath in tableview called button , made indexpath.row tag number of button itself. added target action done , created @ibaction. i'm trying change image of heart button red nothing happens. there problem passing uiimage button via sender. have no errors. , if = statement working correctly. here code:

    override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! postscelltableviewcell          cell.heartbutton.tag = indexpath.row         cell.heartbutton.addtarget(self, action: "liked:", forcontrolevents: .touchupinside) return cell }  @ibaction func liked (sender: uibutton){          if == false{         sender.imageview?.image = uiimage(contentsoffile: "red-heart.png")             = true         }         else{             sender.imageview?.image = uiimage(contentsoffile: "white-heart-hi.png")             = false         }        // self.tableview.reloaddata()     } 

try instead.

    if == false{         sender.setimage(uiimage(named: "red-heart.png"), forstate: .normal)         = true     } else {         sender.setimage.setimage(uiimage(named: "white-heart-hi.png"), forstate: .normal)         = false     } 

Comments