[Solved] UITextView if line numbers is 2 [duplicate]


For Count the number of lines of text

int numLines = textView.contentSize.height / textView.font.lineHeight;
NSLog(@"number of line - %d", numLines);

And for iOS 7 see this Question/Answer.

EDIT for iOS < 7:

This is proper answer

UIFont *myFont = [UIFont boldSystemFontOfSize:13.0]; // your font with size
CGSize size = [textView.text sizeWithFont:myFont  constrainedToSize:textView.frame.size  lineBreakMode:UILineBreakModeWordWrap]; // default mode
int numLines = size.height / myFont.lineHeight;
NSLog(@"number of line - %d", numLines);

8

solved UITextView if line numbers is 2 [duplicate]