1.扫码
AVCaptureDevice* device; 获取设备
AVCaptureDeviceInput* input 输入
AVCaptureMetadataOutput* output 输出
AVCaptureSession* session; 链接输入和输出的桥梁
AVCaptureVideoPreviewLayer* preview 扫码的界面的layer
- (void)captureOutput:(AVCaptureOutput*)captureOutput didOutputMetadataObjects:(NSArray*)metadataObjects fromConnection:(AVCaptureConnection*)connection
从这里面获取扫码的结果
2.识别相册里的二维码
CIDetector*detector 获取图片中的信息
CIDetector*detector = [CIDetectordetectorOfType:CIDetectorTypeQRCode
context:[CIContextcontextWithOptions:nil]
options:detectorOptions];
具体的实现在demo
https://github.com/hkkh/KHQRManger.git
// 代码可能有问题 需要可以自己修改