1016-07-6, 7 adaptation issues

Source: Internet
Author: User

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

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.