iOS 被鍵盤遮擋時,帶有textfield的tableview自動上移
阿新 • • 發佈:2019-02-10
- (void)textFieldDidBeginEditing:(nonnull UITextField *)textField{
UITableViewCell * cell=(UITableViewCell *)[[textField superview] superview];
NSIndexPath *indexPath=[self.myTableView indexPathForCell:cell];
if (indexPath.section==0) {
}else {
[UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
[UIView setAnimationDuration:0.30f];
_point = self.myTableView.center;
self.myTableView.center = CGPointMake(SCREENSIZE.width, 120);
[UIView commitAnimations];
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
UITableViewCell * cell=(UITableViewCell *)[[textField superview] superview];
NSIndexPath *indexPath=[self.myTableView indexPathForCell:cell];
if (indexPath.section==0) {
}else {
[UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
[UIView setAnimationDuration:0.30f];
self.myTableView.center = _point;
[UIView commitAnimations];
}
}
UITableViewCell * cell=(UITableViewCell *)[[textField superview] superview];
NSIndexPath *indexPath=[self.myTableView indexPathForCell:cell];
if (indexPath.section==0) {
}else {
[UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
[UIView setAnimationDuration:0.30f];
_point = self.myTableView.center;
self.myTableView.center = CGPointMake(SCREENSIZE.width, 120);
[UIView commitAnimations];
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
UITableViewCell * cell=(UITableViewCell *)[[textField superview] superview];
NSIndexPath *indexPath=[self.myTableView indexPathForCell:cell];
if (indexPath.section==0) {
}else {
[UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
[UIView setAnimationDuration:0.30f];
self.myTableView.center = _point;
[UIView commitAnimations];
}
}