En supposant que vous implémentez vos validations dans la méthode tableView: commitEditingStyle: forRowAtIndexPath: de votre objet de protocole UITableViewDatasource, vous devriez pouvoir définir editAccessoryType et editingAccessoryView sur la cellule.
//After validation fails....
UITableViewCell *aCell;
aCell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
// validations are done and you need to ignore the delete
if (aCell.showingDeleteConfirmation){
aCell.editingAccessoryView = nil;
aCell.editingAccessoryType = UITableViewCellAccessoryNone;
}
Si vous le souhaitez, vous pouvez envelopper les modifications dans un bloc d'animation pour animer la modification.
Vous pouvez également basculer l'état d'édition de la cellule.
//After validation fails....
UITableViewCell *aCell;
aCell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
if (aCell.showingDeleteConfirmation){
aCell.editing = NO;
aCell.editingAccessoryView = nil;
aCell.editing = YES;
}
Salut, Utilisez-vous la méthode reloadData de UITableView après l'annulation de l'uer? – ISDi
Bonjour ISDi, J'utilise une feuille d'action à des fins de validation. La réponse suivante va comme un gant. Merci. – BigJoke