0

私の- (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;
}
4

1 に答える 1

1

あら!どうでも...

私は質問を削除しますが、将来誰かが同じ間違いをするかもしれないので、私はそれを残しておきます.

私のクライアントには、テーブルを常に編集モードにするという奇妙な要件があるため、小さな丸い赤い行の削除ボタンが常に表示されています。したがって、私は私の中に持っていself.tableview.editing = YES;ましたviewDidLoad。tableview.editing はチェックマークを非表示にし、それをオフにすると元に戻ります。

ああ!

画像ビューなどで使用できるチェックマークのアートワークを送ってくれるよう、彼を説得する必要があると思います。

(私はすでに、常に編集モードにならないように彼を説得しようとしましたが、喜びはありません。)

于 2013-08-01T02:57:19.173 に答える