@interface CommentViewController ()<UITextFieldDelegate,UIGestureRecognizerDelegate>{
CGRect normalRect; //默认高度
}
//监控键盘
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBegin:) name:UIKeyboardWillShowNotification object:nil ];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyEnd:) name:UIKeyboardWillHideNotification object:nil ];
#pragma mark textField Methods-
- (void)keyBegin:(NSNotification *) notif{
CGRect keyBoardRect = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
[UIView animateWithDuration:.3 animations:^{
self.commentView.frame = CGRectMake(self.commentView.frame.origin.x, normalRect.origin.y- keyBoardRect.size.height, self.commentView.frame.size.width,self.commentView.frame.size.height);
} completion:^(BOOL finished) {
}];
}
- (void)keyEnd:(NSNotification *) notif{
[UIView animateWithDuration:.3 animations:^{
self.commentView.frame = normalRect; //恢复默认高度
} completion:^(BOOL finished) {
}];
}