2010-11-30 5 views

Répondre

30

vous recevez actuellement chemin d'index sélectionné pour une table:

NSIndexPath *path = [tableView indexPathForSelectedRow]; 

Désélectionnez ligne sélectionnée:

[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES]; 
2
NSIndexPath *path = [tableView indexPathForSelectedRow]; 

La ligne ci-dessus jetteront EXC BAD ACCESS si aucune vente est sélectionné afin de garder une trace de votre cellule sélectionnée avec la variable d'instance NSIndexPath et seulement deselect quand il est actuellement sélectionné avec isSelected propriété de la cellule.

UITableViewCell *cell = [tableView cellForRowAtIndexPath:someIndexPath]; 
if(cell.isSelected) { 
    [tableView deselectRowAtIndexPath:someIndexPath animated:YES]; 
} 
Questions connexes