- (void)viewWillAppear:(BOOL)animated
{
一次性获得数据,方便在- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 中绘制单元。
[tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kCellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCellIdentifier] autorelease];
}
switch (indexPath.row) {
case 0: {
cell.text = [NSString stringWithFormat:NSLocalizedString(@"Mean Download Time: %fs", @"Mean Download Time format"), MeanDownloadTimeForParserType(indexPath.section)];
} break;
case 1: {
cell.text = [NSString stringWithFormat:NSLocalizedString(@"Mean Parse Time: %fs", @"Mean Parse Time format"), MeanParseTimeForParserType(indexPath.section)];
} break;
case 2: {
cell.text = [NSString stringWithFormat:NSLocalizedString(@"Mean Total Time: %fs", @"Mean Total Time format"), MeanTotalTimeForParserType(indexPath.section)];
} break;
}
return cell;
}
本文介绍了一个UITableView的数据加载方法以及如何配置不同类型的UITableViewCell来显示特定格式的内容。通过在viewWillAppear方法中调用reloadData实现数据刷新,并根据不同indexPath配置单元格中的数据显示。

被折叠的 条评论
为什么被折叠?



