title: UITextView's text going beyond bounds
body: <p>I have a non-scrollable UITextView with it's layoutManager maximumNumberOfLines set to 9, which works fine, but, I cannot seem to find a method in NSLayoutManager that restricts the text to not go beyond the frame of the UITextView.</p>
  
  <p>Take for example in this screenshot, the cursor is on the 9th line (the 1st line is clipped at top of screenshot, so disregard that). If the user continues to type new characters, spaces, or hit the return key, the cursor continues off screen and the UITextView's string continues to get longer.</p>
  
  <p><img src="https://i.stack.imgur.com/AfNa5.png" alt="enter image description here"></p>
  
  <p>I don't want to limit the amount of characters of the UITextView, due to foreign characters being different sizes.</p>
  
  <p>I've been trying to fix this for several weeks; I'd greatly appreciate any help.</p>
  
  <p>CustomTextView.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface CustomTextView : UITextView &lt;NSLayoutManagerDelegate&gt;
  
  @end
  </code></pre>
  
  <p>CustomTextView.m</p>
  
  <pre><code>#import "CustomTextView.h"
  
  @implementation CustomTextView
  
  - (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self)
      {
          self.backgroundColor = [UIColor clearColor];
          self.font = [UIFont systemFontOfSize:21.0];
          self.dataDetectorTypes = UIDataDetectorTypeAll;
          self.layoutManager.delegate = self;
          self.tintColor = [UIColor companyBlue];
          [self setLinkTextAttributes:@{NSForegroundColorAttributeName:[UIColor companyBlue]}];
          self.scrollEnabled = NO;
          self.textContainerInset = UIEdgeInsetsMake(8.5, 0, 0, 0);
          self.textContainer.maximumNumberOfLines = 9;
      }
      return self;
  }
  
  - (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect
  {
      return 4.9;
  }
  
  @end
  </code></pre>
  
  <p><strong>Update, still not resolved</strong></p>