IOS Chinese source File Processing Method

Source: Internet
Author: User

I studied smcalloutview in the morning and found that the author directly put the image as a string in the source code file. The advantage of this is that the resource files that the program depends on are directly placed together with the code. You only need to copy the source code to use them. It's easy to think about it: first convert the image resource into a base64 string, and then declare the string as a constant. When using nsdata, convert it to uiimage:

+ (UIImage *)embeddedImageNamed:(NSString *)name {    if ([UIScreen mainScreen].scale == 2)        name = [name stringByAppendingString:@"$2x"];        SEL selector = NSSelectorFromString(name);        if (![(id)self respondsToSelector:selector]) {        NSLog(@"Could not find an embedded image. Ensure that you've added a category method to UIImage named +%@", name);        return nil;    }        // We need to hush the compiler here - but we know what we're doing!    #pragma clang diagnostic push    #pragma clang diagnostic ignored "-Warc-performSelector-leaks"    NSString *base64String = [(id)self performSelector:selector];    #pragma clang diagnostic pop        UIImage *rawImage = [UIImage imageWithData:[self dataWithBase64EncodedString:base64String]];    return [UIImage imageWithCGImage:rawImage.CGImage scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];}

 

In addition, I suspect there is another reason why the author is so hard to explain. The image resources of smcalloutview are actually uicalloutview resources extracted from IOS using the uikit-artwork-Extractor. The latter is a private API and is not open. Can I use base64 to perform mounting detection? After all, using this method to process image resources means that the system's image cache cannot be used.

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.