UIImage can be initialized in the following two ways:
The first way to initialize: "Note that when using this initialization, if PNG format can not give suffix name, according to the resolution of the screen to match the picture"
uiimage *image = [UIImage imagenamed:@ v_red_heart_ Selected "];
The second way to initialize: "You must splice the full name of the picture, otherwise the image's path is empty"
nsstring *filepath = [[NSBundle mainbundle] pathforresource:@ "V_red_heart_ Selected@x.png "Oftype:nil];
The difference between two ways:
The first way to initialize:
Using imagenamed: First time reading, put the picture in the cache, the next time you use the same name of the picture to read directly from the cache; advantages: Convenient and quick, only the first time to use a little slower, then use will be a little faster Disadvantage: If only one time is used in the current project, memory will be wasted. "The inside of this program is closed before it is released."
The second method of initialization:
When you initialize a picture using Initwithcontentsoffile, each time you read it according to the path, it does not occupy memory, and you should choose this method if the picture is used only once in the current project.