ios - Force UITableView to load cells before it is displayed -
i need force uitableview
load cells based on datasource , resulting uitableview
height before displayed on ui. have other logic implemented based on height. rows have dynamic height , content inside cells autolayouted. why coudln't calculate manually (or don't know how). crucial in case height before uitableview
displayed.
please advise.
now, requirement find height of cells filled data
by this, can find height of cells before displaying them on tableview
yes, can using below code:
/****/ - (cgfloat)heightforbasiccellatindexpath:(nsindexpath *)indexpath { nsstring *cellidentifier= @"identifier"; static dispatch_once_t oncetoken; static uitableviewcell *cell = nil; dispatch_once(&oncetoken, ^{ cell = [self.tableview dequeuereusablecellwithidentifier:cellidentifier]; }); /**set data , values on cell*/ cgfloat height = [self calculateheightforconfiguredsizingcell:cell]; // nslog(@"height @ indexpath %ld --> %f",(long)indexpath.row, height); return height; } - (cgfloat)calculateheightforconfiguredsizingcell:(uitableviewcell *)sizingcell { [sizingcell setneedslayout]; [sizingcell layoutifneeded]; cgsize size = [sizingcell.contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize]; cgfloat height = size.height; return height + 1.0f; // add 1.0f cell separator height }