【发布时间】:2014-06-08 19:30:04
【问题描述】:
我有一个从 url 地址加载标题和图像的表格视图。由于我添加了图像,因此滚动不流畅。我已将背景更改为清除。图像分辨率低。我更喜欢使用 url 访问它们,而不是下载图像并在应用程序上重新上传。期待您的解决方案,使滚动顺畅。谢谢
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableCell" forIndexPath:indexPath];
NSString *str = [[feeds objectAtIndex:indexPath.row] objectForKey: @"title"];
[[cell textLabel] setNumberOfLines:0]; // unlimited number of lines
[[cell textLabel] setFont:[UIFont systemFontOfSize: 16.0]];
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.TitleLabel.text=str;
UIImage *pImage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:feeds2[indexPath.row]]]];;
[cell.ThumbImage setImage:pImage];
return cell;
}
【问题讨论】:
-
在后台线程上加载图像,而不是在主线程上。
标签: ios objective-c uitableview uiimage