QR Code Scanning in ios application

前端 未结 5 1728
借酒劲吻你
借酒劲吻你 2020-12-04 06:37

I need to integrate QR-code reader in app and found a tutorial for it.

I downloaded Z-bar sdk from this link.

Here is what I had done.

In the QRscann

5条回答
  •  春和景丽
    2020-12-04 07:33

    You can use my own framework for QRCodeReader.

    https://www.cocoacontrols.com/controls/qrcodereader

    How to use

    1. Embeded Binaries
    2. Drag and drop UIView in your view controller.
    3. Change Class of UIVIew.
    4. Bind your UIView.

    Paste "M1, M2" methods in your view controller (i.e. "ViewController.m")

    "M1" viewDidLoad

    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.
        self.title = @"QR Code Reader";
        [qrCodeView setDelegate:self];
        [qrCodeView startReading];
    }
    

    And here the delegate methods: "M2" QRCodeReaderDelegate

    
    #pragma mark - QRCodeReaderDelegate
    - (void)getQRCodeData:(id)qRCodeData {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"QR Code" message:qRCodeData preferredStyle:UIAlertControllerStyleAlert];
    
        UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
        [alertController addAction:cancel];
    
        UIAlertAction *reScan = [UIAlertAction actionWithTitle:@"Rescan" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [qrCodeView startReading];
        }];
        [alertController addAction:reScan];
        [self presentViewController:alertController animated:YES completion:nil];
    }
    

    Thanks.

提交回复
热议问题