iphone - Reuse cells of a scroll view -


i using scrollview display various items in horizontal fashion.

how can "reuse cells" conserve memory:

edit: apologies not being clear. plan place few labels , and imageview inside each imageview keen reuse each time instead of instantiating new items each time. e.g. change image's , update labels instead of re-create it.

// implement viewdidload additional setup after loading view, typically nib. - (void)viewdidload {     [super viewdidload];      // load images our bundle , add them scroll view //  nsuinteger i;     (int = 0; <= 150; i++)     {         nsstring *imagename = @"tempimage.jpg";         uiimage *image = [uiimage imagenamed:imagename];         uiimageview *imageview = [[uiimageview alloc] initwithimage:image];          // setup each frame default height , width, placed when call "updatescrolllist"         cgrect rect = imageview.frame;         rect.size.height = kscrollobjheight;         rect.size.width = kscrollobjwidth;         imageview.frame = rect;         imageview.tag = i;  // tag our images later use when place them in serial fashion         [self.bestsellscrollview addsubview:imageview];         [imageview release];     }      [self layoutscrollimages];  // place photos in serial layout within scrollview }  - (void)layoutscrollimages {     uiimageview *view = nil;     nsarray *subviews = [self.bestsellscrollview subviews];      // reposition image subviews in horizontal serial fashion     cgfloat curxloc = 0;     (view in subviews)     {         if ([view iskindofclass:[uiimageview class]] && view.tag > 0)         {             cgrect frame = view.frame;             frame.origin = cgpointmake(curxloc, 0);             view.frame = frame;              curxloc += (kscrollobjwidth);         }     }      // set content size can scrollable     [self.bestsellscrollview setcontentsize:cgsizemake((150 * kscrollobjwidth),                                                         [self.bestsellscrollview bounds].size.height)]; } 

if mean happens respect uitableviewcell in uitableview, not possible in horizontal scroller.

the reusable cells property table view provided system , not applicable horizontal scroller.

you have write on own logic in order achieve it, perhaps! question though. tuned other answers in case if possible.


Comments