iphone - Using dequeueReusableCellWithIdentifier causes images used as a repeating background to leak out of the cell -
iphone - Using dequeueReusableCellWithIdentifier causes images used as a repeating background to leak out of the cell -
am trying utilize 3 images background cell. top image, middle (repeating image) , bottom image. if utilize dequeuereusablecellwithidentifier works fine, start scrolling table images don't remain within cell.
see attached image.
this troublesome code
uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:@"cellidentifier"]; }
this works fine, assume memory hog.
uitableviewcell *cell = [[uitableviewcell alloc] initwithframe:cgrectzero];
what best way have best of both worlds? i.e. working , not beingness memory intensive.
update complete cell row @ index path function
uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:@"cellidentifier"]; } uiimageview *img1 = [[uiimageview alloc] initwithframe:cgrectmake(5.0, 0.0, 310.0, 8.0)]; img1.image = [uiimage imagenamed:@"top.png"]; uiimageview *img2 = [[uiimageview alloc] initwithframe:cgrectmake(5.0, 8.0, 310.0, [pullrefreshtableviewcontroller heightforexpandingcell:text])]; img2.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"middle.png"]]; uiimageview *img3 = [[uiimageview alloc] initwithframe:cgrectmake(5.0, [pullrefreshtableviewcontroller heightforexpandingcell:text] + 8.0, 310.0, 8.0)]; img3.image = [uiimage imagenamed:@"tempbottom.png"]; [[cell contentview] addsubview:img1]; [[cell contentview] addsubview:img2]; [[cell contentview] addsubview:img3]; homecoming cell;
i advise using single stretchable image cell background, , adding in single imageview (with appropriate resizing masks) when creating cell (i.e. when cell== nil).
you adjust height in heightforrowatindexpath method.
at moment adding image views every time cell reused, end dozens of them in each cell, , different heights, looks mess.
if stretchable image doesn't work you, should creating image views 1 time stated above, , adjusting frames when cell re-used.
alternatively, since image looks nil more gray rounded corners, calayer's borderwidth, bordercolor, borderradius properties.
iphone ios uitableview uiimageview uiimage
Comments
Post a Comment