1.在初始化方法里邊注冊鍵盤坐標移動的通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];//監(jiān)聽鍵盤的坐標的變化
2喇喉,實現輸入框隨鍵盤移動的方法
-(void)keyboardChangeFrame:(NSNotification*)notification
{
//從通知中取出動畫速率
intcurve = [[notification.userInfoobjectForKey:UIKeyboardAnimationCurveUserInfoKey]intValue];
//取出動畫時間
floatduration = [[notification.userInfoobjectForKey:UIKeyboardAnimationDurationUserInfoKey]floatValue];
//取出鍵盤動畫結束后鍵盤的frame
CGRectendFrame = [[notification.userInfoobjectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue];
[UIViewanimateWithDuration:durationanimations:^{
[UIViewsetAnimationCurve:curve];
_commentView.frame=CGRectMake(0, endFrame.origin.y-H_i6real(38),self.view.frame.size.width,H_i6real(38));
_commentTableView.frame=CGRectMake(W_i6real(10), endFrame.origin.y-(self.view.frame.size.width/2)-H_i6real(10),self.view.frame.size.width-W_i6real(80+10),self.view.frame.size.width/2-H_i6real(38));
}];
}