Textview Frame 被挤压无法恢复原状?

Textview Frame is become squeez and cannot come back to its original form?

keyboardWillShow 方法实现:

 - (void)keyboardWillShow:(NSNotification *)notification 
    {

     [UIView beginAnimations:nil context:nil];
     CGRect endRect = [[notification.userInfo 
     objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
      CGRect newRect = txtNotes.frame;
      //Down size your text view
      newRect.size.height -= endRect.size.height;
      txtNotes.frame = newRect;
      [UIView commitAnimations];
    }

keyboardWillHide方法实现:

  - (void)keyboardWillHide:(NSNotification *)notification
   {
      // Resize your textview when keyboard is going to hide
       UIEdgeInsets contentInsets = UIEdgeInsetsZero;
       txtNotes.contentInset = contentInsets;
       txtNotes.scrollIndicatorInsets = contentInsets;

   }

两件事:

1) META:您应该在每个代码行之前添加 4 个空格,以使代码正确显示。

2) 这看起来像是一个基本的约束问题。您应该检查故事板的 Auto Layout