Egoimageview is a third-party class library that implements asynchronous loading and caching of network images. The third-party class library with the same functions also has sdwebimage. However, compared with the installation and use of the two class libraries, egoimageview is simpler. The following describes how to use egoimageview:
1. Download egoimageview and Its Related Class Libraries
Egoimageloading
Add egocache, egoimagebutton, egoimageview, and egoimageloader to the project (copy)
2. Use egoimagviewCodeAs follows:
Egoimageview * imageview = [[egoimageview alloc] initwit2d-aceholderimage: [uiimage imagenamed: @ "placeholder.png"]; imageview. imageurl = [nsurl urlwithstring: @ "http ://...... /images/1.jpg"]; imageview. frame = cgrectmake (x, x); [self. view addsubview: imageview];
Placeholder.png is the image displayed when the image is not loaded. After the loading process is completed, the image corresponding to the URL is displayed.
3. It is worth special attention that egoimageview has a very strange bug.
When the imageview image is loaded, you need to reset the imageurl attribute of egoimageview when you want to change the image URL and use egoimageview to load the image. However, it is important to note that this method must be executed in the main thread. I have made a lot of effort to find this bug, I searched several pages on Google in English to find a coder that is the same as the fallen man. So I got the following code:
[Imageview into mselecw.mainthread: @ selector (setimageurl :) withobject: [nsurl urlwithstring: @ "http: //.../images/2.jpg"] waituntildone: No];