Two-dimensional code

Source: Internet
Author: User

Generate two-dimensional code

Prerequisites: you need to import the following code

1. Define a Uiimageview attribute in the Viewcontroller. m file, storing the QR code

@property (Weak, nonatomic) Iboutlet Uiimageview *imageview;

2. Write the following code in the Viewdidload method

Self.imageView.image = [Qrcodegenerator qrimageforstring:@ "Huan Huan" imageSize:self.imageView.frame.size.width];

QR Code Scan: On the real machine can

Prerequisites: need to introduce a system framework

#import <AVFoundation/AVFoundation.h>

1. Defining attributes

@property (nonatomic, strong) avcapturesession *capturesession;

2. Write the following code in Viewdidload

Self.capturesession = [[Avcapturesession alloc] init];

Customizing the Camera Interface

Avcapturedevice *device = [Avcapturedevice Defaultdevicewithmediatype:avmediatypeaudio];

Avcapturedeviceinput *input = [Avcapturedeviceinput deviceinputwithdevice:device error:nil];

Set the input stream for the session

[_capturesession Addinput:input];

Set the output stream of the session

Avcapturemetadataoutput *output = [[Avcapturemetadataoutput alloc] init];

To set the proxy for the output stream

[OutPut setmetadataobjectsdelegate:self Queue:dispatch_get_main_queue ()];

Set the type of sweep code

[_capturesession Addoutput:output];

Two-dimensional code and human face

[OutPut Setmetadataobjecttypes:@[avmetadataobjecttypeqrcode, Avmetadataobjecttypeface]];

Creating a camera coating

Avcapturevideopreviewlayer *layer = [Avcapturevideopreviewlayer layerWithSession:self.captureSession];

Layer.frame = Self.view.bounds;

[Self.view.layer Addsublayer:layer];

Start scanning

[Self.capturesession startrunning];

Two-dimensional code

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.