【发布时间】:2011-12-05 11:33:06
【问题描述】:
我正在尝试向多个表格单元格添加一个简单的 UIActivityIndicatorView。活动指示器是每个单元格的相同对象。但是,由于某种原因,它只显示在表格的最后一个单元格上。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryView = _activityView;
cell.textLabel.text = [_tableItems objectAtIndex:indexPath.row];
cell.textLabel.textColor = DARK_GRAY;
cell.detailTextLabel.text = [_tableSubtitles objectAtIndex:indexPath.row];
cell.detailTextLabel.textColor = DARK_GRAY;
return cell;
}
在我看来,这段代码应该让每个单元格对象获取指向同一个活动视图的指针,因此每个单元格的附属视图应该显示相同的活动指示器。但是,除了 tableView 上的最后一个之外,任何单元格的辅助视图上都没有结果,它按预期显示活动指示器。感谢您提供有关为什么会发生这种情况的任何提示。
【问题讨论】:
标签: ios uitableview