ios - AutoLayout in UITableview with dynamic cell height -


for dynamic height of table view cell take reference link. using auto layout in uitableview dynamic cell layouts & variable row heights

here custom cell constrains

here code of tableview data source , delegate methods

-(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section;   {        return arrtemp. count;   }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier=@"autolayoutcell";  autolayouttableviewcell *cell=(autolayouttableviewcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell==nil) {     (id currentobject in [[nsbundle mainbundle] loadnibnamed:@"autolayouttableviewcell" owner:self options:nil]) {         if ([currentobject iskindofclass:[uitableviewcell class]]) {             cell = (autolayouttableviewcell *)currentobject;             break;         }     } }  cell.iblbllineno.text=[nsstring stringwithformat:@"line:%i",indexpath.row]; cell.iblbllinetext.text=[arrtemp objectatindex:indexpath.row]; [cell setneedsupdateconstraints]; [cell updateconstraintsifneeded];  cgsize expectedlinelabelsize = [cell.iblbllinetext.text sizewithfont:cell.iblbllinetext.font constrainedtosize:cgsizemake(280, 1000) linebreakmode:nslinebreakbytruncatingtail]; cell.iblbllinetext.numberoflines=expectedlinelabelsize.height/17;  cgrect frmlbl=cell.iblbllinetext.frame; frmlbl.size.height=expectedlinelabelsize.height; cell.iblbllinetext.frame=frmlbl;  return cell; }  - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {  autolayouttableviewcell *cell = (autolayouttableviewcell *)[ibtblautolayoutexample cellforrowatindexpath:indexpath];  cell.iblbllineno.text=[nsstring stringwithformat:@"line:%i",indexpath.row]; cell.iblbllinetext.text=[arrtemp objectatindex:indexpath.row];  [cell setneedsupdateconstraints]; [cell updateconstraintsifneeded];  cgsize expectedlinelabelsize = [cell.linelabel.text sizewithfont:cell.linelabel.font constrainedtosize:cgsizemake(280, 1000) linebreakmode:nslinebreakbywordwrapping];   cell.iblbllinetext.numberoflines=expectedlinelabelsize.height/17; cgrect frmlbl=cell.iblbllinetext.frame; frmlbl.size.height=expectedlinelabelsize.height; cell.iblbllinetext.frame=frmlbl;  cgfloat height = [cell.contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize].height; height += 1.0f;  return height; }  - (cgfloat)tableview:(uitableview *)tableview estimatedheightforrowatindexpath:(nsindexpath *)indexpath {      autolayouttableviewcell *cell = (autolayouttableviewcell *)[ibtblautolayoutexample cellforrowatindexpath:indexpath];   cgsize expectedlinelabelsize = [cell.iblbllinetext.text sizewithfont:cell.iblbllinetext.font constrainedtosize:cgsizemake(280, 1000) linebreakmode:nslinebreakbytruncatingtail];   return expectedlinelabelsize.height;  } 

i have 2 questions :

  1. my issue error exe_bad_excess near line

    autolayouttableviewcell *cell = (autolayouttableviewcell *)[ibtblautolayoutexample cellforrowatindexpath:indexpath];  

    in heightforrowatindexpath , estimatedheightforrowatindexpath.

  2. why have write label text in both cellforrowatindexpath , heightforrowatindexpath?

also, missing needed achieve dynamic height cell?


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -