title: How to get n lines of text from UITextView in iOS
body: <p>In my application i need to restrict to user enter 7 lines only in UITextView. When he tries enter text in 8 line we need to stop allowing editing and show an alert message. Its working fine by using CGSize of getting UITextView text. </p>
  
  <p>But when user enters text in UITextView as Paste its not allowing if text is more than 7 lines. As per requirement <strong><em>i need to get the 7 lines of Text from entred (Copied &amp; Pasted ) in to UITextView.</em></strong></p>
  
  <pre><code>    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string
      {
          NSString *temp = [textView.text stringByReplacingCharactersInRange:range withString:string]
          CGSize size = [temp sizeWithFont:textView.font constrainedToSize:CGSizeMake(textView.frame.size.width,999) lineBreakMode:UILineBreakModeWordWrap];
          int numLines = size.height / textView.font.lineHeight;
          if (numLines &lt;= 8)
          {
              return true;
          }
  
  //Alert
      return false;
  }
  </code></pre>
  
  <p>Please help me in this issue.
  Thanks in Advance.</p>