加载视图时是否可以加载UITableView的所有单元格,以便在滚动时不加载它们? (我将显示加载屏幕,而这样做)UITableView:加载所有单元格
请,这是唯一的办法,在我的项目(对不起太复杂解释为什么^^)
编辑:
好让我解释一下你,就是我做的肯定:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = [NSString stringWithFormat:@"Identifier %i/%i", indexPath.row, indexPath.section];
CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
NSDictionary *currentReading;
if (cell == nil)
{
cell = [[[CustomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
UILabel *label;
UIView *separator;
if(indexPath.row == 0)
{
// Here I'm creating the title bar of my "table" for each section
}
else
{
int iPr = 1;
do
{
currentReading = [listData objectAtIndex:iPr-1];
iPr++;
} while (![[currentReading valueForKey:@"DeviceNo"] isEqualToString:[devicesArr objectAtIndex:indexPath.section]] ||
[readingresultsArr containsObject:[currentReading valueForKey:@"ReadingResultId"]]);
[readingresultsArr addObject:[currentReading valueForKey:@"ReadingResultId"]];
//
// ...
//
}
}
return cell;
}
发生在DO-while循环我的错误: “的ListData”是与它的多个字典的数组。 我的问题是,当我慢慢滚动桌子时,一切都很好,但是当我快速滚动到视图的末尾,然后滚动到中间位置时,出现iPr出错的错误阵列的范围。所以问题是,第一部分的最后一行已经添加到“readingresultsArr”中,但尚未加载或想要再次加载。 这就是为什么我想要一次加载所有单元格的原因。为表中的每一行
[self tableView: self.tableView cellForRowAtIndexPath: indexPath];
:
“请,这是我的项目的唯一方式” - 它当然**不应该**。请解释一下,即使它很复杂。除此之外,这在内存管理方面也是非常糟糕的错误。 – 2012-09-04 17:52:24
@ H2CO3我编辑了我的问题并更详细地描述了我的问题。希望您能够帮助我。 – Michael
你能解释一下你想用'do ... while'循环完成什么吗?看起来你正在试图找到一个符合某些标准的对象,然后建立一个新的阵列,但为什么你需要在那里做到这一点?你可以在重新加载表之前建立这个数组吗? –