iOS 二维码生成、扫码 、QR code

需要框架:

1、lizbqrencode :生成二维码的库

2、SSQBImagePicker:获取相册

3、ZBarSDK:扫描二维码的开源库


1、扫描二维码(解析二维码)

需要导入:AVFoundation.framework、CoreMedia.framework、CoreVideo.framework、QuartzCore.framework、libiconv.dylib、lib.dylib

需要:项目的target-setting-Enable Bitcode 设置为NO

2、生成二维码(需要lizbqrencode)

需要导入:AVFoundation.framework、CoreMedia.framework、CoreVideo.framework、QuartzCore.framework、libiconv.dylib、lib.dylib

导入:#import "CJWQRCode.h"

_codeimg = [[UIImageView alloc]initWithFrame:CGRectMake((kScreen_Width - 200)/2, (kScreen_Height - 200)/2, 200, 200)];

[self.view addSubview:_codeimg];

[_codeimg qrcodeWith:[NSString stringWithFormat:@"%@",@"https://www.baidu.com"]];



iOS 二维码生成、扫码 、QR code_第1张图片
导入的框架


3、导入可能出现的问题

(1)出现以下的话,需要导入:libz.dylib

Undefined symbols for architecture arm64:

"_iconv", referenced from:

_qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)

"_iconv_open", referenced from:

_qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)

"_iconv_close", referenced from:

_qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


(2)出现以下,需要:项目的target-setting-Enable Bitcode 设置为NO

does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64


(3)解决lizbqrencode 导入报错:

在  .pch配置文件中把全局引用的.h文件全放在

#ifdef __OBJC__

#endif

之中。到处问题完美解决。


代码下载地址:https://github.com/zhimeiyue/QRcode

你可能感兴趣的:(iOS 二维码生成、扫码 、QR code)