ios - My tableview scrolling is very slow -


-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {   static nsstring *cellidentifier=@"cell"; magazinelistcell* cell=(magazinelistcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if(cell==nil) {     nsarray *arr=[[nsbundle mainbundle]loadnibnamed:@"magazinelistcell" owner:nil options:nil];     cell=(magazinelistcell *)[arr objectatindex:0];     [cell setdelegate:self];     [cell setselectionstyle:uitableviewcellselectionstylenone]; }  nsmutablearray *arr=[[nsmutablearray alloc]init]; nsinteger startindex; nsinteger endindex;  if(islandscape) {     startindex=indexpath.row*3;     if (startindex+3>[self.arrmagazine count ])     {         endindex=[self.arrmagazine count];     }     else     {         endindex=startindex+3;     } } else {     startindex=indexpath.row*2;     if (startindex+2>[self.arrmagazine count])     {         endindex=[self.arrmagazine count];     }     else     {         endindex=startindex+2;     } } (int x=startindex; x<endindex; x++) {     [arr addobject:[self.arrmagazine objectatindex:x]]; } [cell setselectedindex:btnsegment.selectedsegmentindex]; [cell contentfortableviewcell:arr setuimode:islandscape] ; arr=nil; return cell;  } 

check reuse identifier being set may creating cell every time.

the main problem going array you're creating every time, looping around populate , passing on cell. should try of setup before need it.


Comments