ios - UITableviewCell height autolayout -
ios - UITableviewCell height autolayout -
i have next uitableviewcell layout, using autolayout handling this
========= | image | name label | | short description label ========= description label
here description label optional, hide/show according content, calculating height of cell on heightforrowatindexpath
using
- (cgfloat)heightfortableview:(uitableview *)tableview cell:(uitableviewcell *)cell atindexpath:(nsindexpath *)indexpath { cell.bounds = cgrectmake(0, 0, cgrectgetwidth(tableview.bounds), cgrectgetheight(cell.bounds)); [cell setneedslayout]; [cell layoutifneeded]; cgsize cellsize = [cell.contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize]; // add together padding cgfloat height = cellsize.height;// + 1; homecoming height; }
even if hide hide description label returning same height cell, missing ?
can suggest best way handle such scenarios autolayout ?
edit 1 : setting empty works there improve way ?
heightforrowatindexpath called rows.so row hiding description label, same row cat set height in heightforrowatindexpath method.
for example. row no 4 want hide description label checking condition.
than in heightforrowatindexpath can check same status same row, , can homecoming height required while not showing description label.
lets say,
if(description.length==0) { homecoming 100;// description label hidden } else { homecoming 140;// description label shown }
ios objective-c uitableview autolayout
Comments
Post a Comment