解决textfield键盘掩盖视图的问题
第三方(一句话解决)三方库链接点击打开链接
IQKeyboardManager *manager = [IQKeyboardManagersharedManager];
manager.canAdjustTextView =YES;
让textField遵守代理方法,然后复制以下代码就可以了
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[selfanimateTextField: textFieldup:YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
[selfanimateTextField: textFieldup:NO];
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up{
constint movementDistance =80;// tweak as needed
constfloat movementDuration =0.3f;// tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIViewbeginAnimations:@"anim"context:nil];
[UIViewsetAnimationBeginsFromCurrentState:YES];
[UIViewsetAnimationDuration: movementDuration];
self.view.frame =CGRectOffset(self.view.frame,0, movement);
[UIViewcommitAnimations];
}