IOS Picture Loading

Source: Internet
Author: User

You are still using myimage = [UIImage imagenamed:@ "Icon.png"];

Title, is not everyone so easy to load the picture AH
MyImage = [UIImage imagenamed:@ "Icon.png"];
So be careful.
This method is OK in a few pictures, or the picture is very small program.
However, in a large number of programs loading pictures, please do not do so.
Why???????

This method looks at the top-level folder of the application bundle by the image of the supplied name. If a picture is found, mount the image to the iphone system cache. That means that the picture is (theoretically) placed in memory as the cache.

Imagine you have more pictures, what is the consequence of ""
Picture cache may not respond to memory warnings and release its objects

Therefore, when using the picture must be careful alloc and release
Recommended Use
NSString *path = [[NSBundle mainbundle] pathforresource:@ "icon" oftype:@ "PNG"];
MyImage = [UIImage Imagewithcontentsoffile:path];

But this method to pay attention, if there is high-definition picture, that is, @2x, you can not automatically get to, you grasp it, do the UI with Imagenamed, to deal with the large map do not load the


The picture is cached
Uiimageview *wallpaper = [[Uiimageview alloc] Initwithimage:
wallpaper = [UIImage imagenamed:@ "Icon.png"];

Do not cache pictures
Uiimageview *wallpaper = [[Uiimageview alloc] Initwithimage:
wallpaper = [UIImage imagewithcontentsoffile:@ "Icon.png"];

IOS Picture Loading

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.