Sto provando a ricaricare un singolo TableViewCell ma scorre verso l'alto ogni volta che lo faccio ... Non sto aggiungendo né cancellando celle, voglio solo cambiare il colore delle celle selezionate .Mantieni offset quando reloadRowsAtIndexPaths
Questo è quello che faccio nel cellForRowAtIndexPath:
SMPChoiceViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChoiceCell" forIndexPath:indexPath];
SMPChoice *choice = self.choices[indexPath.row - 1];
cell.choiceTextLabel.text = choice.text;
if ([self.selectedChoices indexOfObject:choice] != NSNotFound) {
cell.choiceTextLabel.textColor = [UIColor purpleColor];
} else {
cell.choiceTextLabel.textColor = [UIColor blackColor];
}
e questo è quello che faccio nel didSelectRowAtIndexPath
if ([self.selectedChoices indexOfObject:choice] != NSNotFound) {
[self.selectedChoices removeObject:choice];
} else {
[self.selectedChoices addObject:choice];
}
CGPoint offSet = [tableView contentOffset];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView setContentOffset:offSet animated:NO];
Ma salta solo, qualsiasi suggerimento?
P.S ho seguito questa discussione ma non ha risolto la mia domanda Calling reloadRowsAtIndexPaths removes tableView contentOffset
Prova UITableViewRowAnimationNone e rimuovere [tableView setContentOffset: Offset animato: NO].; – Sathya
Ciao Sathya ... Ancora scorre verso l'alto e ora non ha quel bel effetto di dissolvenza hehehe: '( – mtet88