6
votes

Swipe pour supprimer l'option dans UitailView Problèmes

Je veux utiliser l'option "Swipe pour supprimer" l'option dans mon projet.

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{

    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        NSDictionary *userData = [_contactsArray objectAtIndex:indexPath.row];
        NSLog(@"delete row %@",userData);
    }
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{

    return YES;
}


4 commentaires

développeur.apple.com/library/ios/documentation/uikit/referenc e / ...


Stackoverflow.com/Questtions/3020922/...


Vous remplacez les méthodes uablesViewelegate correctes. Mais définissez-vous la propriété "Modification" de votre UitaireView vers Oui N'importe Où dans votre code? Si tel est le cas, cela entraînera la visibilité des signes rouges moins les signes.


@ hw731 merci pour votre réponse. Ça marche pour moi, j'ai fait une petite erreur


4 Réponses :


1
votes

Essayez ceci:

 - (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
        }    
    }


0 commentaires

0
votes

On dirait que vous tournez le drapeau tableview.editing sur afin que les lignes apparaissent avec le signe moins. Essayez Gox> Self.tableview.editing = Oui; et faites-le NO ou commencez simplement que la ligne de sortie.


0 commentaires

9
votes

Vous remplacez les méthodes de délégué correctes pour «Swipe pour supprimer» la fonctionnalité. En ce qui concerne les signes moins:

Masquer le signe moins Signe Comme ceci: P>

self.yourTableView.editing = YES;


0 commentaires

3
votes

Créez d'abord votre vue sur la table et définissez la méthode du délégué et de votre source de données à cela.

- (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
        }    
    }


0 commentaires