我有一个 UITableView,我在其中使用 nib 文件将数据添加到一行。我刚刚展示了表格,如果用户点击该行,什么都不会发生,它只是一个报告。
但是,我有很多行,有些行出现在同一日期,我想添加一个细行来对这些行进行分组。
如果不能,我可以在 cellForRowAtIndexpath 中执行此操作吗?
这是我当前的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ReportCell";
ReportCell *cell = (ReportCell *) [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"ReportCell"
owner:nil options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = ((ReportCell *) currentObject);
break;
}
}
}
最佳答案
最好的方法可能是使用部分。
看一眼
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
关于ios - 当 iOS 上的行不同时,如何简单地插入日期标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4097757/