【发布时间】:2014-09-26 09:15:00
【问题描述】:
我懒得在表格视图中加载一些图像
我按照以下教程进行操作 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;
}
加上滚动表格视图,它也会中断。我该如何解决这个问题?任何建议。
【问题讨论】:
-
在将图像保存到 _diskCachePath 之前,调整图像大小然后保存。当您滚动表格视图时,它将加载较小尺寸的图像,并且滚动看起来很流畅。
标签: ios objective-c image uitableview