如何让 uitableview 一次加载多个部分?
How to make uitableview load many sections at a time?
我有一个显示图片的UITableView,每张图片都有一个名称;由于某些原因,我必须将名称作为一个部分header,图片作为一个部分行,主要代码是像这样:
- (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;
我的问题是:每次,图片都不会加载,直到它的顶部出现在屏幕上;
我想一次加载很多图片,但事实是当图片顶部显示在屏幕上时加载了图片;
由于在新单元格即将进入视图之前不会调用要求您提供单元格的委托方法,因此您必须在委托方法之外的某个位置预加载图像。
我有一个显示图片的UITableView,每张图片都有一个名称;由于某些原因,我必须将名称作为一个部分header,图片作为一个部分行,主要代码是像这样:
- (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; 我的问题是:每次,图片都不会加载,直到它的顶部出现在屏幕上; 我想一次加载很多图片,但事实是当图片顶部显示在屏幕上时加载了图片;
由于在新单元格即将进入视图之前不会调用要求您提供单元格的委托方法,因此您必须在委托方法之外的某个位置预加载图像。