【问题标题】:Integrating SDWebImage With YouTube Api将 SDWebImage 与 YouTube Api 集成
【发布时间】:2012-08-14 06:21:22
【问题描述】:

我正在尝试将 SdWebImage 与 Youtube Api 集成,以获取缩略图图像以缓存它们,从而摆脱 UITableView 中的滚动问题。问题是 Youtube API 提供一个用于缩略图 NSDATA 的 URL,它可以转换回UIImage 对象,但 SDWebImage 是获取图像的 URL,以最有效的方法管理图像。

Youtube API 方法:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]]];
UIImage * image = [UIImage imageWithData:data];

SDWebImage 方法

[cell.imageView setImageWithURL:[NSURL URLWithString:[_objects objectAtIndex:indexPath.row]]
               placeholderImage:[UIImage imageNamed:@"placeholder"]];

请告诉我们如何解决这个问题。

【问题讨论】:

    标签: ios5 youtube-api sdwebimage


    【解决方案1】:

    我认为你在考虑这个问题。你应该可以这样做:

    NSURL *thumbnailURL = [NSURL URLWithString:[[thumbnails objectAtIndex:indexPath.row] URLString]]];
    
    [cell.imageView setImageWithURL:thumbnailURL
                   placeholderImage:[UIImage imageNamed:@"placeholder"]];
    

    【讨论】:

    • 非常感谢先生它成功了.....只是我们必须对其进行轻微更改.. NSURL *thumbnailURL = [NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]] ]; [cell.imageView setImageWithURL:thumbnailURL placeholderImage:[UIImage imageNamed:@"placeholder"]];
    猜你喜欢
    • 2014-09-11
    • 2014-03-28
    • 2021-06-12
    • 1970-01-01
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 2021-11-10
    相关资源
    最近更新 更多