Ios 将单元格添加到uitableView,如Mail.app
我想在UItableView中添加单元格,就像在ipad上的mail.app中一样。在我的单元格中,我有UITextFields,我已经更改了这个方法来设置焦点Ios 将单元格添加到uitableView,如Mail.app,ios,ipad,uitableview,Ios,Ipad,Uitableview,我想在UItableView中添加单元格,就像在ipad上的mail.app中一样。在我的单元格中,我有UITextFields,我已经更改了这个方法来设置焦点 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath{ NSLog(@"%d",newIndexPath.row); UITextField* field = (UITextField
- (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];
}
但当我点击其中一个单元格时,我添加了两个单元格(比如mail.app),但是我的文本字段标签不会更新,我也无法设置焦点=(.如果我调用reloaddata方法,它会在Begging和after为所有单元格调用-cellForRowAtIndexPath这个新单元格,它也不会工作。听起来你要找的是一种内置的单元格样式,名为
UITableViewStyleSubtitle
,你可以像iPad Mail.app一样自定义字幕。看一看在中的此页面,您可以将UITableViewCell
的字幕设置为所需的文本。此外,iOS文档还提供了有关的更多信息