J'ai mis en place un style de vue de table groupé personnalisé en utilisant le code suivant dans cellForRowAtIndexPath. Chaque cellule reçoit une nouvelle vue d'arrière-plan et ses coins sont arrondis en fonction de sa position dans la section. J'utilise ce style tout au long de mon application et dans diverses vues, j'utilise des animations pour ajouter et supprimer des lignes. (En utilisant [tableview insertRowsAtIndexPaths:], etc).Arrière-plans personnalisés UITableViewCell, quand recharger, etc.
Si la dernière rangée d'une section est insérée ou retirée, j'ai besoin de pouvoir recharger les coins de la vue d'arrière-plan des cellules. Comment puis-je faire cela sans appeler [tableview reloadData] ou même reloadCellsAtIndexPaths? Ces deux fonctions gâchent les animations d'insertion et de suppression de cellules. Y a-t-il quelque part où je peux mettre cette définition de coin de fond qui serait appelée au moment opportun? Comment le tableau par défaut groupé fait-il cela?
Désolé, ce n'est pas clair. Demandez des éclaircissements et je vais modifier. Merci! :)
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:[self styleForCellAtIndexPath:indexPath]
reuseIdentifier:cellIdentifier] autorelease];
// Theme the cell
TableCellBackgroundView *backgroundView = [[TableCellBackgroundView alloc] initWithFrame:cell.frame];
TableCellBackgroundView *selectedBackgroundView = [[TableCellBackgroundView alloc] initWithFrame:cell.frame];
selectedBackgroundView.selectedStyle = YES;
// top row, without header
BOOL header = [self tableView:aTableView heightForHeaderInSection:indexPath.section]!=0;
if (indexPath.row == 0 && (!header || tableTheme==kTableThemeSimple)) {
backgroundView.topRadius = 6;
selectedBackgroundView.topRadius = 6;
}
// bottom row
if (indexPath.row == [self tableView:aTableView numberOfRowsInSection:indexPath.section]-1) {
backgroundView.bottomRadius = 6;
selectedBackgroundView.bottomRadius = 6;
}
cell.backgroundView = backgroundView;
cell.selectedBackgroundView = selectedBackgroundView;
cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor clearColor];
}
}
Existe-t-il un moyen propre de détecter dans les cellules la disposition ou l'aperçu des coins? Cela ne me dérange pas de sous-classer UITableViewCell, je ne peux pas penser à une façon dont cela aiderait .. – Dash