【发布时间】:2009-06-06 17:07:33
【问题描述】:
出于性能考虑,通常重用 UITableView 的单元格。 有没有办法对 TableView 标题的视图做同样的事情? 我说的是委托方法返回的那些:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
我尝试执行以下操作,但似乎没有按预期工作:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *CellIdentifier = @"Header";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil) {
cell = [self getHeaderContentView: CellIdentifier];
}
return cell;
}
有没有办法重用标题的视图?
【问题讨论】:
-
从 iOS 6 开始,您现在拥有
UITableViewHeaderFooterView,它使用了重用标识符。 -
但目前您不能将 UITableViewHeaderFooterView 与 UI Builder 一起使用。
标签: iphone cocoa-touch