我正在使用 SDWebImage 将图像加载到我的表格单元格中 - 但是,直到我选择该行之后,当我看到图像在表格从屏幕上动画显示时出现时,图像才会出现。当我从导航 Controller 单击返回时,图像就在那里。
这可能只是网络速度问题还是我遗漏了什么?如果有影响的话,目前仅在模拟器上运行
代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier] autorelease];
}
// Configure the cell...
NSUInteger row = [indexPath row];
// Here we use the new provided setImageWithURL: method to load the web image
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://mydomain.com/uploads/news1.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
}
谢谢
最佳答案
已修复,占位符图像不正确。抱歉浪费了大家的时间...
关于ios4 - 使用 SDWebImage 将图像加载到 UITableView 单元格时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7500497/