title: UITextView loses height
body: <p>I have simple textview with dynamic height, because I want it to conform to its content. But every time when I finish typing text, and begin to do it again, the textview loses his height and comes back to initial height. And yes, I'm a new to iOS development. Here is my code</p>
  
  <pre><code>-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
  
  if ([text isEqualToString:@"\n"]) {
      [textView endEditing:true];
      return false;
  }
  
  return true; 
  }
  
  
  -(void)textViewDidChange:(UITextView *)textView{
  
      self.myTextView.text = self.myTextView.text.uppercaseString;
  
      int lines = self.myTextView.contentSize.height / self.myTextView.font.lineHeight;
      NSLog(@"number of lines: %d", lines);
  
      if (lines &gt;=2) {
  
          if (lines != optionLineChek) {
  
              CGSize size = [self.myTextView systemLayoutSizeFittingSize:self.myTextView.contentSize];
              CGRect frame = self.myTextView.frame;
              frame.size.height = size.height;
              self.myTextView.frame = frame;
  
          }
  
      } 
   }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/fD4gr.gif" rel="nofollow">the problem</a></p>