ios - UIButton color in UIScrollView is set to wrong color when scrolling -
ios - UIButton color in UIScrollView is set to wrong color when scrolling -
i have uitableview 20 rows , in every row have 1 uiimageview, 4 uitextview , 3 uibutton.
my tablview loads perfectly, when scroll, of uibutton shows wrong color. illustration 1 of rows should have yellowish uicolor, when scroll unbutton in row became yellow!
here code :
func tableview(tableview: uitableview!, cellforrowatindexpath indexpath: nsindexpath!) -> uitableviewcell! { var cell:timelinetableviewcell? = tableview.dequeuereusablecellwithidentifier("timelinetableviewcell") as? timelinetableviewcell if (cell == nil){ cell = nsbundle.mainbundle().loadnibnamed("timelinetableviewcell", owner: self, options: nil)[0] as? timelinetableviewcell } cell!.namelabel.text = self.usernamea[indexpath.row] cell!.screennamelabel.text = "@" + self.screennamea[indexpath.row] cell!.tweetlabel.text = self.tweeta[indexpath.row] cell?.avatarimage.hnk_setimagefromurl(nsurl(string:self.avatara[indexpath.row])) cell?.avatarimage.layer.cornerradius = 4 cell?.avatarimage.layer.maskstobounds = true if langa[indexpath.row] == "fa" { cell?.tweetlabel.textalignment = nstextalignment.right } else if langa[indexpath.row] == "ar" { cell?.tweetlabel.textalignment = nstextalignment.right } cell?.favbutton.settitle(favorite_counta[indexpath.row], forstate: .normal) cell?.retweetbutton.settitle(retweet_counta[indexpath.row], forstate: .normal) if favoriteda[indexpath.row] { cell?.favbutton.settitlecolor("#ffe066".uicolor, forstate: .normal) } if retweeteda[indexpath.row] { cell?.retweetbutton.settitlecolor("#70b894".uicolor, forstate: .normal) } cell?.retweetbutton.tag = indexpath.row; cell?.retweetbutton.addtarget(self, action: "retweetpressed:", forcontrolevents: uicontrolevents.touchupinside) cell?.favbutton.tag = indexpath.row; cell?.favbutton.addtarget(self, action: "favpressed:", forcontrolevents: uicontrolevents.touchupinside) homecoming cell; }
it appear in uibutton. what's wrong?
use identifier, tableview doesn't redraw cells, have declare 2 cellidentifier. 1 cell first color , sec other color.
ios objective-c uitableview swift uibutton
Comments
Post a Comment