i have custom tableviewcell has product name, product image, , button. in same tableviewcontroller there search bar pull specific products based on name. when search can click on button product , change color, green red , text change "original color" "changed color". works until cancel search, button reverts original form. function, if need know else let me know. in advance.
@ibaction func changecoloraction(sender: uibutton) { sender.backgroundcolor = uicolor.redcolor() sender.settitle("changed color", forstate: uicontrolstate.normal) } this call function:
override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = self.tableview.dequeuereusablecellwithidentifier("cell") as! customsearchcell var user : useritem if(tableview == self.searchdisplaycontroller?.searchresultstableview) { user = self.filteredproducts[indexpath.row] } else { user = self.productsarray[indexpath.row] } cell.followbutton.addtarget(self, action: "changecoloraction:", forcontrolevents: .touchupinside) cell.configurecellwith(user) return cell }
when search cancelled or renewed, table rebuilds "filterdproducts" or "productsarray" arrays. have change color of button when create cell inside tableview function , store information if product "followed" or not.
Comments
Post a Comment