Alo*_*ver 0 iphone uitableview
这是我现在面临的问题:
我有很多UITableViews,每个都有两个部分(根据需要,任何时候只显示一个).第一部分有3个单元格,可能需要调整大小.因此,我正在使用heightForRowAtIndexPath.
第二部分最多可以有3.000个单元格,全部使用默认高度44点.
我的heightForRowAtIndexPath确定它是处理来自第1部分还是第2部分的单元格,然后是度量(第1部分)还是立即返回默认值(第2部分).
通过使用此方法,大型表视图需要一段时间才能显示,因为在这种情况下(大于约1.000个单元格),heightForRowAtIndexPath是性能问题.
我的问题是:有没有办法只调整第一部分中提出的3个单元格?任何方式可能强制只为indexPath.section == 0调用heightForRowAtIndexPath?
如果它有任何区别,我正在使用分组表视图.
谢谢.
Nea*_*l L 11
heightForRowAtIndexPath如果它在你的委托中实现,将被调用.如果您只想更改第一部分中的值,那么只需使用一个简单的if语句即可.这可能看起来像:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
// Test to see what section you're in
if ([indexPath section] == 0) {
// return the height for the first section
} else {
// return the height for everything other than the first section
}
}
Run Code Online (Sandbox Code Playgroud)
干杯.
| 归档时间: |
|
| 查看次数: |
2521 次 |
| 最近记录: |