在我的- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
,我最初有:
if ([UploadManager isFileUploaded: filename])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
但是,考虑到我的 UploadManager 中可能存在错误,我将其更改为:
if ([UploadManager isFileUploaded: filename])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
用于检测。但是,我的单元格仍然没有显示复选标记。我究竟做错了什么?!
谢谢!
编辑:
没关系,但以防万一,这是我的全部(大部分)cellForIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"fileList-cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault
reuseIdentifier: CellIdentifier];
}
int row = [indexPath row];
// Create cell layout
NSString *filename = [self.tableItems objectAtIndex: row];
// Name label
UILabel *nameLabel = (UILabel*)[cell viewWithTag: nameLabelTag];
if (nameLabel == nil)
{
nameLabel = [UILabel new];
// blah blah, snip
[cell addSubview: nameLabel];
}
nameLabel.text = filename;
[nameLabel sizeToFit];
CGRect rect = nameLabel.frame;
rect.origin.x = 50;
nameLabel.frame = rect;
// More UI added to cell here. Snip
// Is uploaded checkmark
if ([UploadManager isFileUploaded: filename])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
return cell;
}