Picture stretching
___________________________________________________
___________________________________________________
1. If the picture is larger, do not use [UIImage imagenamed:@ "Big.png"]; To load.
-(void) viewdidload
{
[Super Viewdidload];
Uiimageview *imageview = [[Uiimageview alloc] init];
Imageview.image = [UIImage imagenamed:@ "AVATAR_VIP"];
NSString *file = [[NSBundle mainbundle] pathforresource:@ "[email protected]" oftype:@ "PNG"];
Imageview.image = [UIImage imagewithcontentsoffile:file];
Imageview.frame = CGRectMake (10, 50, 34, 34);
[Self.view Addsubview:imageview];
This method loads the picturethere will be no cache, suitable for loading large pictures, one-time pictures (less frequently used)
[UIImageImagewithcontentsoffile: <# (NSString *) #>];
This method loads the picturethere will be a cache, suitable for loading small pictures, more frequently used pictures
[UIImageimagenamed: @ "Searchbar_textfield_background"];
//Recommended: 1. Small pictures can be placed in the images.xcassets; 2. Big picture suggestions in supporting files
}
___________________ This is the nsbunld mainbunld path, not the sandbox path ________________________________
________________ Figure 1 _______________________________________________________________ Figure 2 ___________________
___________ Figure 3 ________
Figure two figure three add up is the sandbox path, the cached picture has the "6/7 adaptation Problem" folder under this level directory. [[NSBundle Mainbundle] pathforresource:@ "avatar_vip@2x" oftype:@ "PNG"]; Look for a picture resource in this level of directory.
1. All images will be compressed inside the assets.car.
2. Whether the picture is placed in [NSBundle Mainbundle], or compressed inside the Assets.car, [UIImage imagenamed:@ "AVATAR_VIP"];
3. In iOS6, the picture is placed inside the Assets.car, [[NSBundle Mainbundle] pathforresource:@ "avatar_vip@2x" oftype:@ "PNG"]; not found. IOS7 can be found. The images placed inside the images.xcassets are cached.
4. Whether it is suitable for a few, as long as the picture is placed under the supporting Files, the picture will appear in the Mainbundle path inside. So just put it in this directory and can be loaded by any means.
5. Images placed inside the Assets.car cannot be loaded by Imagewithcontentsoffile.
Above to be sorted out.
6. Supporting Files can only put pictures, not to see the characteristics of the picture, put images.xcassets the picture below can be.
7. [[NSBundle Mainbundle] pathforresource:@ "avatar_vip@2x" oftype:@ "PNG"]; is the full path of the loaded picture.
1016-07-6, 7 adaptation issues