0
我想将单元格添加到UItableView中,就像在ipad上的mail.app中一样。在我的小区我有UITextFields,我必须改变这种方法将焦点设置将单元格添加到uitableView中像Mail.app
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath{
NSLog(@"%d",newIndexPath.row);
UITextField* field = (UITextField *) [tblView viewWithTag: newIndexPath.row];
int l_cellNum = field.tag;
if(l_cellNum == 1 && isAddedNewRow == FALSE){
isAddedNewRow = TRUE;
[cellsArray insertObject:@"CC" atIndex:1];
[cellsArray insertObject:@"BCC" atIndex:2];
CGRect tvbounds = [tblView bounds];
[tblView setBounds:CGRectMake(tvbounds.origin.x,
tvbounds.origin.y,
tvbounds.size.width,
tvbounds.size.height)];
NSIndexPath *path1 = [NSIndexPath indexPathForRow:1 inSection:0];
NSIndexPath *path2 = [NSIndexPath indexPathForRow:2 inSection:0];
NSArray *indexArray = [NSArray arrayWithObjects:path1,path2,nil];
[tblView insertRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationTop];
[tblView reloadRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
}
[field becomeFirstResponder];
}
但是当我点击到小区之一,我加2个细胞(如mail.app),但我的文本框的标签不更新,我不能把重点放在它=(如果我打电话reloaddata方法它调用-cellForRowAtIndexPath与这个新细胞在开始和所有细胞之后,它不会工作太多。