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