IPhone Development notes (20) How to Use egoimageview and precautions

Source: Internet
Author: User

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];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.