目前我设计在用户按下键盘的返回按钮时在UITableView中添加新的行单元格。但问题是在添加4或5个uitableview单元格后,新单元格隐藏在键盘下。当按下返回键但是失败时,我正试图解决调整uitableview的问题。
以下是我的代码。
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if ([text isEqualToString:@"\n"]) {
CoachPadItem *newCoachPadItem = [[CoachPadItem alloc]init];
newCoachPadItem.coachpadDescription = @"NULL";
newCoachPadItem.coachpadTagId = @"0";
[_tagPointsArray addObject:newCoachPadItem];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[_tagPointsArray count]-1 inSection:0];
[_coachpadTableView beginUpdates];
CoachPadPointCell *cell = (CoachPadPointCell*)[_coachpadTableView cellForRowAtIndexPath:0];
[cell.txtPoint becomeFirstResponder];
isType = TRUE;
if ([isDelete isEqualToString:@"1"]) {
isDelete = @"2";
}
[_coachpadTableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[_coachpadTableView endUpdates];
return NO;
}
return YES;
}
答案 0 :(得分:0)
添加4-5细胞后,执行以下操作:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.3];
[UIView setAnimationBeginsFromCurrentState:YES];
CGRect frame = self.view.frame;
frame.origin.y = - 170;
self.view.frame = frame;
[UIView commitAnimations];
输入完成后再次将y设置为0