1
我正試圖添加一個簡單的UIActivityIndicatorView到多個表格單元格。活動指示器是每個單元的相同對象。但是,由於某些原因,它僅顯示在表格的最後一個單元格中。在所有tableview單元格中的活動指示器,只顯示在最後一個
- (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上的最後一個單元格外,其他任何單元格的附件視圖都不會顯示任何結果,它會按預期方式顯示活動指示符。感謝有關發生這種情況的任何提示。