Activation de glisser à supprimer tout en affichant les commandes de réorganisation sur UITableView
-
07-07-2019 - |
Question
Je souhaite autoriser la réorganisation de UITableViewCell
et la suppression par balayage pour supprimer, mais pas via le cercle de suppression rouge.
- (void)loadView
{
[super loadView];
[table setEditing:YES animated:NO];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Perform delete here
}
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
// Perform move here
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
De plus, j'ai essayé de désactiver le mode d'édition et d'appeler - [UITableViewCell setShowsReorderControl: YES]
sans succès.
(source: booleanmagic.com )
La solution
Je pense que vous devrez faire une interception d'événement tactile personnalisée.
En anglais: si le doigt est déplacé, x distance, horizontalement à travers la cellule, dans cette cellule uniquement, affichez le contrôle de suppression.
Vous ne savez pas comment désactiver les cercles à gauche, mais j'estime qu'il s'agit d'une propriété telle que "montre le contrôle de la réorganisation"