ios - How to calculate tableView row height and pass value to heightForRowAtIndexPath -


i've tableview custom cells. each cell has different interface, elements. have different sizes. each cell has different type of elements , count. these elements created dynamically, i'm creating them, making frames , adding subviews.

so problem heightforrowatindexpath executes before cellforrowatindexpath i'm creating row , constructing interface , don't know how pass calculated height heightforrowatindexpath

how can count row height before , pass value heightforrowindexpath correct drawing of tableview?

if cell view complex , every component's height depending on data source. can try create view in heightforrowindexpath method , cache created view dictionary in view controller , use directly in cellforrowatindexpath. in way need create view once when user scrolling table. if datasource not changing frequently, can reuse cached view in heightforrowindexpath well.

and if tableview has lot of rows, should return approximate value height in estimatedheightforrowatindexpath speed loading process of view controller. otherwise during loading tableview, try calculate row's height may requires lot of time.

but don't think cell complex. if uitextlabels depends on datasource height, can calculate height label, add other components' height fixed.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -