title: Resize UItextview according to it's content in iOS7
body: <p>I'm trying to resize a text view according to content &amp; also it's sibling and parent container.</p>
  
  <p>Below code is working fine in iOS 6</p>
  
  <pre><code>   if (/* less than ios 7 */) {
          CGRect frame = _textView.frame;
          CGSize conSize = _textView.contentSize;
          CGFloat difference = conSize.height - frame.size.height;
  
          frame.size.height += difference;
          _textView.frame = frame;
  
          UIScrollView *parentView = (UIScrollView *)_textView.superview;
          // adjust views residing below this text view.
  
          // sibling view
          UIView *belowView = // access it somehow
          CGRect frame1 = belowView.frame;
  
          frame1.origin.y += difference;
          belowView.frame = frame1;
          // adjust parent scroll view, increase height.
          CGSize frame3 = parentView.contentSize;
  
          frame3.height += difference;
          parentView.contentSize = frame3;
      } else {
         // tried
         [_textView sizeToFit]; 
         [_textView layoutIfNeeded];
         [parentView sizeToFit]; 
         [parentView layoutIfNeeded];
      }
  </code></pre>
  
  <p>Tried to follow iOS 7 solution from:
  <a href="https://stackoverflow.com/questions/19049532/how-do-i-size-a-uitextview-to-its-content-on-ios-7">How do I size a UITextView to its content on iOS 7?</a></p>
  
  <p>but not working.</p>
  
  <p>Any pointers?</p>
  
  <p><strong>Working code solution from @NSBouzouki</strong></p>
  
  <pre><code>if (/* ios 7 */) {
               [_textView.layoutManager ensureLayoutForTextContainer:_textView.textContainer];
              [_textView layoutIfNeeded];
  }
              CGRect frame = _textView.frame;
              CGSize conSize = _textView.contentSize;
              CGFloat difference = conSize.height - frame.size.height;
  
              frame.size.height += difference;
              _textView.frame = frame;
  
              UIScrollView *parentView = (UIScrollView *)_textView.superview;
              // adjust views residing below this text view.
  
              // sibling view
              UIView *belowView = // access it somehow
              CGRect frame1 = belowView.frame;
  
              frame1.origin.y += difference;
              belowView.frame = frame1;
              // adjust parent scroll view, increase height.
              CGSize frame3 = parentView.contentSize;
  
              frame3.height += difference;
              parentView.contentSize = frame3;
  </code></pre>