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與這個新細胞在開始和所有細胞之後,它不會工作太多。