ios - heightForRowAtIndexPath - how to default to maximum element height of cell -


i have been developing couple of tableviews now. feel wasting time implementing heightforrowatindexpath time. there way default height maximum element y value of row, constructed cellforrowatindexpath adding default padding?

i asking myself, why method not in default ios , developers may override method, if cellforrowatindexpath memory consuming.

the following code show how implement our call -heightforrowatindexpath:

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath; {   nsstring *text = [items objectatindex:[indexpath row]];    cgsize constraint = cgsizemake(cell_content_width - (cell_content_margin * 2), 20000.0f);    cgsize size = [text sizewithfont:[uifont systemfontofsize:font_size] constrainedtosize:constraint linebreakmode:uilinebreakmodewordwrap];    cgfloat height = max(size.height, 44.0f);    return height + (cell_content_margin * 2); } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -