0

次のコードを使用しています

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return YES if you want the specified item to be editable.
    return YES;
}

// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //add code here for when you hit delete
    }
}

-(void)swipePressed:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint p = [gestureRecognizer locationInView:self.myTable];
    NSIndexPath *indexPath = [self.myTable indexPathForRowAtPoint:p];
    if (indexPath == nil)
        NSLog(@"long press on table view but not on a row");
    else
    {
        [[self.myTable cellForRowAtIndexPath:indexPath] setEditingAccessoryType: UITableViewCellEditingStyleDelete];
    }
}

swipePressed は実行されますが、削除ボタンは表示されません...

4

1 に答える 1