如何让uitableview一次加载多个部分?

时间:2015-01-26 02:27:27

标签: ios objective-c uitableview

我有一个UITableView来显示图片,每张图片都有一个名字;由于某种原因,我必须将名称作为一个部分标题,并将图片作为一个部分行,主要代码是这样的:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [dataList count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     ...
      return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
      ...
      return view;
}

图片大到640 * 640; 我的问题是:每次,图片都不会加载,直到屏幕顶部显示; 我想一次加载很多图片,但事实是当图片顶部显示在屏幕上时会加载图片;

1 个答案:

答案 0 :(得分:2)

由于要求您获取单元格的委托方法不会被调用,直到新单元格即将进入视图,您必须在委托方法之外的某处预加载图像。