Why do you use it?
(Original address: Http://blog.csdn.net/niu_gao)
Sdwebimage is a library that downloads pictures from a Web site, and it expands the Uiimageview class. Uiimageview could have downloaded the image directly from the website, but it did not consider caching the picture, causing the network to be accessed whenever the picture was displayed. And Sdwebimage solves the problem (of course, not just this one).
Download location
Https://github.com/rs/SDWebImage
Compile
After downloading, directly open the project to compile.
Used by other projects
There are several ways to use it in other projects, and the simplest is to add a reference to a class, project, to another project.
The steps are as follows:
L in other projects, the name of the project on the popup menu.
L Select Add files to "XXX".
L Select the Sdwebimage project file and select copy items if needed.
L DOT Add.
Compile, pass. Because of the lack of a library source code, this library is called LIBWEBP. Location: HTTPS://GITHUB.COM/WEBMPROJECT/LIBWEBP.
Please download version 0.4.3, otherwise the compilation will not pass. What I'm saying is now, in a few months, it's going to be a higher version.
Copy the SRC directory of LIBWEBP to the VENDORS/LIBWEBP in Sdwebimage. Re-compile, pass.
However, shipping your project will collapse (provided your project uses the Sdwebimage function). You also need to add the link option:-O BJC.
If the operation still fails at this point, you will also need to add a reference to Imageio.framework in "buildphases".
code example:
# Import <SDWebImage/UIImageView+WebCache.h> ...
-(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];
}
// we use Sd_setimagewithurl: to load Web Image
[Cell.imageviewsd_setimagewithurl:[nsurl
urlwithstring:@ "http://www.domain.com/path/to/image.jpg"]
Placeholderimage: [UIImage imagenamed:@ "placeholder.png"];
cell.textlabel.text= @ "My Text" ;
return cell;
}
(Original address: Http://blog.csdn.net/niu_gao)
Use block
// we use to load the web image
Sd_setimagewithurl:
[nsurlurlwithstring:@ "http://www.domain.com/path/to/image.jpg "]
Placeholderimage:imagenamed:@ "placeholder.png"
Completed:nserrornsurl *imageurl) {
... completion code here ...
}
];
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Getting Started with Sdwebimage