ios - Table view cell reload first cell content -
this how table populated :
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { cellnewsinfo *cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; if (!cell) { cell=[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"cell"]; } // set cell int storyindex = [indexpath indexatposition: [indexpath length] - 1]; nsstring *titlearticle=[[stories objectatindex: storyindex] objectforkey: @"title"]; titlearticle = [titlearticle stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; if (indexpath.row==0) { scr=[[uiscrollview alloc] initwithframe:cgrectmake(0, 0, 320, 200)]; scr.tag = 1; scr.autoresizingmask=uiviewautoresizingnone; [cell addsubview:scr]; [self setupscrollview:scr]; uipagecontrol *pgctr = [[uipagecontrol alloc] initwithframe:cgrectmake(120, 170, 80, 36)]; [pgctr settag:12]; pgctr.backgroundcolor = [uicolor clearcolor]; pgctr.numberofpages=5; pgctr.tintcolor=[uicolor redcolor]; pgctr.pageindicatortintcolor=[uicolor bluecolor]; self.pagecontrol.hidden=yes; pgctr.currentpageindicatortintcolor = [uicolor redcolor]; pgctr.autoresizingmask=uiviewautoresizingnone; [cell addsubview:pgctr]; } else{ cell.title.text=titlearticle; cell.title.numberoflines=2;
why when scroll , first cell reloading ? want have scroll view once @ beginig .
the reason scrollview being added again cells being reused once deallocated.
you should creating own custom cells if going display multiple cells types in 1 tableview, or using 2 different cell identifiers depending on if row 0.
cellnewsinfo *cell; if (indexpath.row == 0) { cell = [tableview dequeuereusablecellwithidentifier:@"scrollcell" forindexpath:indexpath]; if ([cell viewwithtag:1]) { scr = [cell viewwithtag:1]; } else { scr=[[uiscrollview alloc] initwithframe:cgrectmake(0, 0, 320, 200)]; scr.tag = 1; } // continue customization here scrollview } else { cell = [tableview dequeuereusablecellwithidentifier:@"cell" forindexpath:indexpath]; // continue customization here without scroll view } return cell;
Comments
Post a Comment