Learn QR codes for iOS and quickly generate QR codes

Source: Internet
Author: User

Learn QR codes for iOS and quickly generate QR codes

 

A QR code is a token that may be used. The speed at which iOS opens the camera to request a QR code is not comparable to that of Android... (Android scans the QR code back and forth ...)

To put it simply, how to convert a piece of information (URL, string) into a QR code and directly upload the code
Steps:
Import CoreImage framework#import
Generate a QR code using the filter CIFilter

# Import ViewController. h # import
  
   
@ Interface ViewController () @ property (weak, nonatomic) IBOutlet UIImageView * iv; @ end @ implementation ViewController-(void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {// 1. instantiate the QR code filter CIFilter * filter = [CIFilter filterWithName: @ CIQRCodeGenerator]; // 2. restore the default attribute of the filter (because the filter may save the last attribute) [filter setDefaults]; // 3. convert the string to NSdata NSData * data = [@ http://www.itheima.com dataUsingEncoding: NSUTF8StringEncoding]; // 4. use KVO to set the filter and pass in data. In the future, the filter will know how to generate a QR code [filter setValue: data forKey: @ inputMessage] through the imported data; // 5. generate the QR code CIImage * outputImage = [filter outputImage]; UIImage * image = [UIImage imageWithCIImage: outputImage]; // 6. set to generate a good QR code to the imageview self. iv. image = image;} @ end
  

 

Related Article

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.