uitableview - Problem with table view in iPhone when adding image to it -


i have following code create cell , add image it

uiimageview* myimage =[[uiimageview alloc]initwithframe:cgrectmake(100,10,40,40)];   [myimage setimage:[uiimage imagenamed:[imagearray objectatindex:indexpath.row]]];   [myimage setbackgroundcolor:[uicolor clearcolor]];   [cell addsubview:myimage];   [myimage release];    cell.textlabel.text=[dataarray objectatindex:indexpath.row];        return cell; 

i using table many purposes , therefore refreshing again , again.... therefore next age overlaps last 1 due problem occurs , both of these images visible(i using transparent background each image).... other problem occurs when need no image..here unable remove last image ...

please help

as might aware when reuse cell 'dequeuereusablecellwithidentifier', returns existing cell instance if present, means if cell exist data exists i.e. image, need clear old image before updating cell new data if new data doesn't have image show old image, guess got point...

ok here solution:

uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if(cell==nil) {    cell = [[uitableviewcell alloc] initwithstyle:uitableviewstyledefault reuseidentifier:cellidentifier];     uiimageview* myimage =[[uiimageview alloc]initwithframe:cgrectmake(100,10,40,40)];     myimage.tag = 1000;      [myimage setbackgroundcolor:[uicolor clearcolor]];      [cell addsubview:myimage];      [myimage release];  } uiimageview *imgview = (uiimageview*)[cell viewwithtag:1000]; imgview.image = nil; imgview.image = [uiimage imagenamed:[imagearray objectatindex:indexpath.row]]; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -