On what factors does the wrapping of the text inside a textview depends. Width of my textview is 160 px and I calculated the width of the incoming text using below mentioned code and it comes out to be 157 px but this text is wrapped in 3 lines… Why so?
CGSize size = [myText sizeWithFont:textViewFont
constrainedToSize:textView.frame.size
lineBreakMode:UILineBreakModeWordWrap];
CGFloat textWidth = size.width;
I thought of dividing width of text with width of the textview to get the number of lines. But calculation returns me 1 whereas I can see 3 lines coming in textview on simulator.
Calculates the size for a string if it would be drawn constrained by the size given as an argument, if the string is too long for the given size constraint it will get truncated to fit.
To get the width of the string if it’s drawn on a single line with no constraints use:
see: http://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html
NOTE: As of iOS7
is deprecated, instead use: