为什么使用SDWebImage的图片在UITableView中只显示一部分,滚动刷新后才完整显示?

2026-04-02 12:251阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计356个文字,预计阅读时间需要2分钟。

为什么使用SDWebImage的图片在UITableView中只显示一部分,滚动刷新后才完整显示?

在UITableView中使用SDWebImage缓存图片,但首次运行时图片只显示部分(随机出现1张或2张)。点击每一行或滚动表格出来屏幕再滚动回来,图片就显示完整了。未知原因。

为什么使用SDWebImage的图片在UITableView中只显示一部分,滚动刷新后才完整显示?

在UITableView中利用SDWebImage来缓存图片,但是第一次运行时图片只出来一部分(随机的出现1张或者2张),点击每一行或者把表格滚动出屏幕再滚动回来,图片就出现了。不知道是

在UITableView中利用SDWebImage来缓存图片,但是第一次运行时图片只出来一部分(随机的出现1张或者2张),点击每一行或者把表格滚动出屏幕再滚动回来,图片就出现了。不知道是什么原因?求解答,谢谢。主要代码如下:

12345678910111213141516171819202122232425262728293031323334353637-(void)viewDidLoad{    [super viewDidLoad];//加载数据    [self setUpStatusData];}-(void)setUpStatusData{    AFHTTPRequestOperationManager *mgr=[AFHTTPRequestOperationManager manager];    NSMutableDictionary *params=[NSMutableDictionary dictionary];    NSString *filePath=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.data"];    WPAccount *account=[NSKeyedUnarchiver unarchiveObjectWithFile:filePath];    params[@"access_token"]=account.access_token;    [mgr GET:@"api.weibo.com/2/statuses/home_timeline.json" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {        NSArray *dictArray=responseObject[@"statuses"];self.statuses=[WPStatus objectArrayWithKeyValuesArray:dictArray];        //刷新表格        [self.tableView reloadData];    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {    }];}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *ID=@"cell";UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];    if (cell==nil) {        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];    }    WPStatus *status=self.statuses[indexPath.row];    cell.textLabel.text=status.text;    WPUser *user=status.user;    cell.detailTextLabel.text=user.name;//加载图片,用框架,有缓存    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:[UIImage imageWithName:@"icon"]];    return cell;}

   

本文共计356个文字,预计阅读时间需要2分钟。

为什么使用SDWebImage的图片在UITableView中只显示一部分,滚动刷新后才完整显示?

在UITableView中使用SDWebImage缓存图片,但首次运行时图片只显示部分(随机出现1张或2张)。点击每一行或滚动表格出来屏幕再滚动回来,图片就显示完整了。未知原因。

为什么使用SDWebImage的图片在UITableView中只显示一部分,滚动刷新后才完整显示?

在UITableView中利用SDWebImage来缓存图片,但是第一次运行时图片只出来一部分(随机的出现1张或者2张),点击每一行或者把表格滚动出屏幕再滚动回来,图片就出现了。不知道是

在UITableView中利用SDWebImage来缓存图片,但是第一次运行时图片只出来一部分(随机的出现1张或者2张),点击每一行或者把表格滚动出屏幕再滚动回来,图片就出现了。不知道是什么原因?求解答,谢谢。主要代码如下:

12345678910111213141516171819202122232425262728293031323334353637-(void)viewDidLoad{    [super viewDidLoad];//加载数据    [self setUpStatusData];}-(void)setUpStatusData{    AFHTTPRequestOperationManager *mgr=[AFHTTPRequestOperationManager manager];    NSMutableDictionary *params=[NSMutableDictionary dictionary];    NSString *filePath=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.data"];    WPAccount *account=[NSKeyedUnarchiver unarchiveObjectWithFile:filePath];    params[@"access_token"]=account.access_token;    [mgr GET:@"api.weibo.com/2/statuses/home_timeline.json" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {        NSArray *dictArray=responseObject[@"statuses"];self.statuses=[WPStatus objectArrayWithKeyValuesArray:dictArray];        //刷新表格        [self.tableView reloadData];    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {    }];}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *ID=@"cell";UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];    if (cell==nil) {        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];    }    WPStatus *status=self.statuses[indexPath.row];    cell.textLabel.text=status.text;    WPUser *user=status.user;    cell.detailTextLabel.text=user.name;//加载图片,用框架,有缓存    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:[UIImage imageWithName:@"icon"]];    return cell;}