0

UITableViewCellEditingStyleDelete特定のセルをスワイプすると、削除ボタンが表示されるテーブルビューが実装されています。
ここで、指がスワイプされたセルをフェードさせて、削除ボタンが表示されたときに後ろのセルがフェードするようにします。助けてくれてありがとう。

これが私のコードです:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
           editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewCellEditingStyleDelete;
}
4

2 に答える 2

1

これをコードに貼り付けるだけです:

- (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell.contentView.alpha != 0.5)
    {
        [cell.contentView setAlpha:0.5];
    }
    else
    {
        [cell.contentView setAlpha:1.0];
    }
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.editing == UITableViewCellEditingStyleDelete)
    {

        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell.contentView.alpha != 0.5)
        {
            [cell.contentView setAlpha:0.5];
        }
        else
        {
            [cell.contentView setAlpha:1.0];
        }
    }
       return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.editing == UITableViewCellEditingStyleDelete)
    {
        [tableView beginUpdates];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
        [self.arrayForRows removeObjectAtIndex:indexPath.row];
        [tableView endUpdates];
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        [cell.contentView setAlpha:1.0];
    }
}
于 2013-03-19T13:34:08.543 に答える
0

クラスで次のメソッドをオーバーライドします

    - (void) setEditing:(BOOL)editing animated:(BOOL)animated {

        [super setEditing:editing animated:animated];

       /*
            your code for style of cell being edited
       */

      }
于 2013-03-19T13:09:50.280 に答える