在viewDidLoad写两条监听通知 监听键盘的弹出和收起
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification
object:nil];
键盘弹出界面上移 键盘收起界面恢复
-(void)keyboardWillShow:(NSNotification*)note{
CGRect keyBoardRect=[note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
_tableView.contentInset = UIEdgeInsetsMake(0,0,keyBoardRect.size.height-35,0);
}
-(void)keyboardWillHide:(NSNotification*)note{
_tableView.contentInset = UIEdgeInsetsZero;
}