UITextView count lines not working as intended -


i'm trying amount of lines in textview. i've searched here solution, every thread has same answer : contentheight/fontlineheight.

i have textview 8 lines, run code , contsize : 1.944413

nslog(@"contsize : %f", desclabel.contentsize.height/desclabel.font.lineheight); 

what doing wrong?

for ios7, version take care can have differents font (and font size) in uitextview :

- (nsuinteger)numberoflinesintextview:(uitextview *)textview {     nslayoutmanager *layoutmanager = [textview layoutmanager];     nsuinteger index, numberoflines;     nsrange glyphrange = [layoutmanager glyphrangefortextcontainer:[textview textcontainer]];     nsrange linerange;      (numberoflines = 0, index = glyphrange.location; index < glyphrange.length; numberoflines++){         (void) [layoutmanager linefragmentrectforglyphatindex:index                                                effectiverange:&linerange];         index = nsmaxrange(linerange);     }     return numberoflines; } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -