Iphone SDK UITextView text length -


how can know text out of fit (that text need scrolled)? have methods or this?

thanks.

use nsstring uikit additions. allow calculate height of string given size , font. can calculate height in way:

 cgfloat textviewwidth = cgrectgetwidth(textview.bounds); cgsize inset = cgsizemake(5.0,5.0); cgsize stringsize = [mystring sizewithfont:textview.font constrainedtosize:cgsizemake(textviewwidth-2*inset.width,1024) linebreakmode:uilinebreakmodewordwrap]; bool textoutoffit = stringsize.height+2*inset.height>cgrectgetheight(textview.bounds); 

note code requires fine tuning. infact text inside text views has internal margin (that took account using inset structure), required text view height higher calculated string height. code ask nsstring calculate size when horizontally constrained in textview boundaries (while 1024 in height maximum uiview height possible). check if returned string height inside or not text view boundaries.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -