//点击输入框触发
- (void)textFieldDidBeginEditing:(UITextField *)textField{
//键盘高度
CGFloat keyboardHeight = 216.0f;
//获取tag
NSLog(@"hhhhh === %d",textField.tag);
//判断键盘高度是否遮住输入框,具体超过多少距离,移动多少距离(自己算好就可以,不一定和这里一样)
if (self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) < 0 &&self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) > -60) {
[self.tableViews setContentOffset:CGPointMake(0, 50) animated:YES];
}
else if (self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) < -60 &&self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) > -120)
{
[self.tableViews setContentOffset:CGPointMake(0, 110) animated:YES];
}
else if (self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) < -120 &&self.tableViews.bounds.size.height - keyboardHeight - 60 * (textField.tag + 1) > -180)
{
[self.tableViews setContentOffset:CGPointMake(0, 170) animated:YES];
}
}
//键盘收回触发
- (void)textFieldDidEndEditing:(UITextField *)textField{
//回归原处
[self.tableViews setContentOffset:CGPointMake(0, 0) animated:YES];
}