ios - why my imageview is shrinking while im scrolling my tabelview cells? -
im dynamically resizing label, in tabelview cell.the number of cells appearing in view fine.but while im scrolling new cells having big size of image view.please let me know.why?
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; tvcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; if (cell == nil) cell = [[tvcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; cell.titlelabel.text = [[[arraydata objectatindex:indexpath.row]valueforkey:@"title"]stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; cell.txtlabel.text = [[[arraydata objectatindex:indexpath.row] valueforkey:@"description"]stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; cell.imglabel.contentmode = uiviewcontentmodescaleaspectfill; [cell.imglabel sd_setimagewithurl:[nsurl urlwithstring:[enclosureurlarray objectatindex:indexpath.row]] placeholderimage:[uiimage imagenamed:@"placeholder"] options:indexpath.row == 0 ? sdwebimagerefreshcached : 0]; [cell.imglabel.layer setmaskstobounds:yes]; [cell.imglabel.layer setcornerradius:2.5f]; [cell setneedslayout]; return cell; }
dequeuereusablecellwithidentifier: forindexpath: never returns nil, delete
if (cell == nil) cell = [[tvcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];
note, setcornerradius inside uitableviewcell make scrolling not smooth. better prepare image rounded corners using core graphics.
[cell setneedslayout];
- uitableviewcell layout cell view automatically, it's excess.if use self sizing cell should set in viewdidload:
tableview.estimatedrowheight = 85.0; tableview.rowheight = uitableviewautomaticdimension;
Comments
Post a Comment