SDWebImage 初步使用 及发现readme文档中的问题

来源:互联网 发布:toro网络意思 编辑:程序博客网 时间:2024/05/25 19:56

1、下载SDWebImage 

下载地址:https://github.com/rs/SDWebImage

2、项目导入相关文件

(1)在Target->Build Phases->Link Binary with Libraries中添加 ImageIO.Framework 和MapKit.Framework

(2)项目中导入SDWebImage文件夹


3、修改Build Settings


target->Build Settings->Linking目录下的Other Linker Flags里面添加:-ObjC


4、查看官方给的readme文档
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *MyIdentifier = @"MyIdentifier";    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];    if (cell == nil)    {        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault                                       reuseIdentifier:MyIdentifier] autorelease];    }    // Here we use the new provided setImageWithURL: method to load the web image    [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]                   placeholderImage:[UIImage imageNamed:@"placeholder.png"]];    cell.textLabel.text = @"My Text";    return cell;}

修改文档中红色部分 

  (1)在官方给出SDWebImage是支持ARC的 所以去掉项目中 autorelease    

  (2)查看SDWebImage中的源码发现 setImageWithURL       已经改为了 sd_setImageWithURL     所以把文档的代码进行相应修改后 放入项目  运行成功。






0 0
原创粉丝点击