objective c - How to avoid refresh cell label in tableview ios on scrolling? -
normally in ios, cells in tableview loading on scrolling. in time i'm setting label text. in case i'm setting text dynamically. when i'm scrolling down it's working expected. when it's scrolling up, it's not working expected. here tried.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"modulecell"; datetableviewcell *cell = (datetableviewcell*)[tableview dequeuereusablecellwithidentifier: cellidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"datetableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; cell.backgroundcolor = [uicolor clearcolor]; cell.selectedbackgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@""]]; cell.selectionstyle = uitableviewcellselectionstylenone; } if (self.newssegmentcontrol.selectedsegmentindex == 1) { [cell.dateview sethidden:no]; }else{ [cell.dateview sethidden:yes]; } nsstring *day = [self getdaylabel:date]; if ([datereturned isequaltostring:day]) { [cell.lbldate settext:@""]; if (self.newssegmentcontrol.selectedsegmentindex == 1) { [cell.dateview sethidden:yes]; } }else{ [cell.lbldate settext:day]; datereturned = day; } }
how may avoid re-draw label text in cell on scrolling?
Comments
Post a Comment