我正在实现 tableView viewForHeaderInSection,其中返回一个加载 UITableViewCell 的 Nib 。
为了解决这个问题,我对其进行了简化。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView* header = [CellFactoryController newSectionHeader];
header.text = "Some Text Depending on the section"
return header;
}
不幸的是,这非常慢,因为我有时有 50 多个标题,当表格绘制时,它们都会从 nib 一次性加载,即使这些标题不在 View 中。
是否有任何现实的方法可以让我克隆 UIViews 从而克隆本例中的标题?或者是我创建硬编码的 UIView 标题的唯一方法?
谢谢
最佳答案
我正在阅读 UINib class 上的 doco那天晚上,它正在讨论如何缓存 Nib 内部结构,以便重复的请求执行得更快。这可能是适合您的选择。
关于iphone - 如何在 tableView viewForHeaderInSection 中使用 NIB 加载的 UIView 而不会影响性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/669759/