Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of QR Code Generation and scanning in iOS third Party Framework

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the iOS third-party framework of QR code generation and scanning example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.

The details are as follows

Import third-party frames libqrencode (generate QR code) and ZBarSDK (QR code scan)

Import header file

# import "QRCodeGenerator.h" # import "ZBarSDK.h" create two buttons click the event button to generate the QR code-(IBAction) erWeiMaBtn1: (id) sender {/ / set the picture box to store the QR code UIImageView * imgView = [[UIImageView alloc] initWithFrame:CGRectMake ((self.view.frame.size.width-200) / 2,100,200,200)]; / / display to the main view [self.view addSubview:self.imgView] / / use the third-party method to realize the desired QR code imgView.image = [QRCodeGenerator qrImageForString:@ "fool" imageSize:self.imgView.frame.size.width];}

Click the button 2 to scan the QR code

-(IBAction) erWeiMaBtn1: (id) sender {/ / set text field (set to global) _ textView = [[UITextView alloc] initWithFrame:CGRectMake ((self.view.frame.size.width-300) / 2,430,300,300) textContainer:nil]; / / set background color _ textView.backgroundColor = [UIColor blueColor]; / / add to the main view [self.view addSubview:self.textView]; ZBarReaderViewController * reader = [ZBarReaderViewController alloc] init]; reader.readerDelegate = self / / hide the bottom control button reader.showsZBarControls = YES; / / set the self-defined interface / / reader.cameraOverlayView = someView (this view can be defined by yourself, of course, you can also add a masked view by [reader.view addSubview:someView], so you can make the desired view effect) / / set the recognition range (the four parameters here are all the view scale ~ ~ Don't get it wrong (the ratio to the left, the ratio to the top, the ratio to the width, the ratio to the height) / / reader.scanCrop = CGRectMake (0,1Pol 1) / / set the identified parameter ZBarImageScanner * scanner = reader.scanner; [scanner setSymbology:ZBAR_I25 / / this parameter and to: the following parameters work together to determine the identified coding range, which can be adjusted according to the requirements to improve the recognition speed. Config:ZBAR_CFG_ENABLE to:0]; [self presentViewController:reader animated:YES completion:nil];} / / here is the delegated method-(void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info {id results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol * symbol = nil; for (symbol in results) break; NSLog (@ "% @", symbol.data); / / print identified data / / set content _ textView.text = symbol.data / / [reader dismissModalViewControllerAnimated:YES];}

Note: fill in the whitelist of available camera scans in info.plist!

Thank you for reading this article carefully. I hope the article "sample Analysis of QR Code Generation and scanning in iOS third Party Framework" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report