starwar2012 2013-04-17 02:51 采纳率: 0%
浏览 2456
已采纳

UITableView显示图片错误

使用GCD从网上加载图片到UITableViewCell中,但是显示的图片不对。

代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    UITableViewCell *cell = [self.newsTable dequeueReusableCellWithIdentifier:@"newsTableCell"];
    NSString *user = [usernames objectAtIndex:[indexPath row]];
    NSString *stat = [statistics objectAtIndex:[indexPath row]];
    NSString *imagePath = [appDelegate.URL stringByAppendingString:@"ImageName"];
    UIImageView *userImageView = (UIImageView *)[self.view viewWithTag:80];
        NSString *imagePath1 = [imagePath stringByAppendingString:[imagepaths objectAtIndex:[indexPath row]]];
        NSURL *url = [NSURL URLWithString:imagePath1];
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue, ^{
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *img = [[UIImage alloc] initWithData:data];
        userImageView.layer.cornerRadius = 5.0;
        userImageView.layer.masksToBounds = YES;
         dispatch_sync(dispatch_get_main_queue(), ^{
        [userImageView setImage:img];
         });
    });
 return cell
}

请帮忙看一下哪里的图片不对,谢谢。

  • 写回答

1条回答

  • ichyan 2013-04-17 11:58
    关注

    没看到你把图片赋值给 cell

    不知道对不对?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题