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; } 

  1. dequeuereusablecellwithidentifier: forindexpath: never returns nil, delete

    if (cell == nil) cell = [[tvcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];

  2. note, setcornerradius inside uitableviewcell make scrolling not smooth. better prepare image rounded corners using core graphics.

  3. [cell setneedslayout]; - uitableviewcell layout cell view automatically, it's excess.

  4. if use self sizing cell should set in viewdidload:

    tableview.estimatedrowheight = 85.0; tableview.rowheight = uitableviewautomaticdimension;


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -