Picture compilation error

Source: Internet
Author: User

Today in the import of a picture, when the real machine test, found an error, but does not affect the operation, but the real machine will not show error errors, and then find the information themselves, it is because the image optimization level can generate a minimum file size, but there is a very bad disadvantage, is very time-consuming, In Xcode there is a setting, this option will probably make your PNG image swell, but you can again Xcode build settings inside settings, such as

By default, commpress PNG files is turned on, closed to run, and found to be a perfect solution for errors.

There is another way to put the picture into the bundle (make bundle method, create a folder, put the content in, and then rename the folder suffix to the bundle is OK). Then add the bundle into the project, as follows

First you need to add #import <QuartzCore/QuartzCore.h> header files

NSBundle *bundle = [NSBundle bundlewithpath:[[nsbundle mainbundle]pathforresource:@ "bundle" ofType:@ "bundle"]];// Get the bundle you set

NSString *imagestr = [Bundle pathforresource:imagename oftype:@ "PNG"];//look for imageName under the path behind the picture is the format, the return value is the absolute path of the picture

[_imgview setimage:[uiimage imagewithcontentsoffile:imagestr]];//adds the picture to the ImageView attempt.

Finally thanked Yumbo main facingsun688 's post.

Picture compilation error

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.