cellForRowAtIndexPath で次のコードを使用して、グループ化されたカスタム テーブルビュー スタイルを設定しました。各セルには新しい背景ビューが与えられ、セクション内の位置に応じて角が丸められます。私はアプリ全体でこのスタイルを使用し、さまざまなビューでアニメーションを使用して行を追加および削除しています。([tableview insertRowsAtIndexPaths:] などを使用)。
セクションの最後の行が挿入または削除された場合、セルの背景ビューの隅を再読み込みできる必要があります。[tableview reloadData]またはreloadCellsAtIndexPathsを呼び出さずにこれを行うにはどうすればよいですか? これらの関数はどちらも、セルの挿入と削除のアニメーションを台無しにします。適切なタイミングで呼び出されるこの背景コーナーの定義を配置できる場所はありますか? デフォルトのグループ化されたテーブルビューはどのようにこれを行いますか?
これが不明な場合は申し訳ありません。説明を求めてください。編集します。ありがとう!:)
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];
}
}