次のように、グループ化されたセクション ヘッダーに使用するUILabel
とを含むカスタム ビューがあります。UIButton
UITableView
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
sectionHeaderView *headerView = [[sectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
[headerView.label setText:[[self tableView:tableView titleForHeaderInSection:section] uppercaseString]];
if (_tableView.editing)
[headerView.button setHidden:NO];
return headerView;
}
ご覧のとおりUITableView
、編集モードのときにボタンを再表示したいと思います。
カテゴリ メソッドを使用してUITableView
visibleHeaders を返すので、reloadData または reloadSections:withRowAnimation を呼び出さずに、表示されているセクション ヘッダー ビューを更新できます。このメソッドは基本的に NSNumber オブジェクトの配列を返し、うまく機能します。
UITableView
編集モードに設定するメソッドは次のとおりです。
- (void)tapThatEditButtonBaby
{
[_tableView setEditing:YES animated:YES];
for (NSNumber *sectionNumber in _tableView.visibleHeaders) {
NSInteger section = [sectionNumber integerValue];
sectionHeaderView *headerView = (sectionHeaderView *)[self tableView:_tableView viewForHeaderInSection:section];
[headerView setBackgroundColor:[UIColor redColor]]; // highlighting view for testing.
}
}
これを解決する良い方法は何でしょうか? 理想的には、私の意見では、 updateSectionAndFooterAtIndex: from のようなものを呼び出せるようにしたいのですがUITableView
、そのような公開されたメソッドはありません... :(