我懒加载在表视图懒惰加载图像在iOS?
一些图片我也跟着下面的教程 Lazy Load ios
这就是我想要显示的单元格样式。
问题是在服务器端图像太大,因此图像视图需要图像的全部宽度和高度。这会导致表格的突然显示。
我无法缩小服务器的大小。没有任何方法可以为所有正在加载的图像设置图像的高度和宽度。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"videoCell1";
CellTableViewCell *cell =(CellTableViewCell *)[tableView1 dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"videoCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.videoNameLabel.text = [videoTitle objectAtIndex:indexPath.row];
cell.videoImage.contentMode = UIViewContentModeScaleAspectFill;
[cell.videoImage sd_setImageWithURL:[NSURL URLWithString:[videoImage objectAtIndex:indexPath.row]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 200;
}
再加上滚动表视图它也会中断。我如何解决这个问题?有什么建议么。
建议看着PHImageManager
示例代码中你_diskCachePath保存图像之前,调整图像的大小,然后保存。 当您滚动表格视图时,它将加载较小尺寸的图像,并且看起来平滑滚动。 – 2014-09-26 09:45:34