iOS仿微信二维码扫描:MQRCodeReaderViewController

jopen 9年前

iOS仿微信二维码扫描:MQRCodeReaderViewController。这个项目基于 QRCodeReaderViewController

What did I modified?

I modified and expanded theQRCodeReaderView, make the interface become more like WeChat.

screenshot

screenshot

Install

CocoaPods

If you're using CocoaPods (You are not?! You should!!) just add

pod 'QRCodeReaderViewController', :git => 'https://github.com/zhengjinghua/MQRCodeReaderViewController.git'

into your Podfile file.

Manually

Download the project and copy theQRCodeReaderViewControllerfolder into your project and then simply#import "QRCodeReaderViewController.h"in the file(s) you would like to use it in.

Usage

- (IBAction)scanAction:(id)sender  {      NSArray *types = @[AVMetadataObjectTypeQRCode];      _reader        = [QRCodeReaderViewController readerWithMetadataObjectTypes:types];        // Set the presentation style      _reader.modalPresentationStyle = UIModalPresentationFormSheet;        // Using delegate methods      _reader.delegate = self;        // Or by using blocks      [_reader setCompletionWithBlock:^(NSString *resultAsString) {          [self dismissViewControllerAnimated:YES completion:^{              NSLog(@"%@", resultAsString);          }];      }];        [self presentViewController:_reader animated:YES completion:NULL];  }    #pragma mark - QRCodeReader Delegate Methods    - (void)reader:(QRCodeReaderViewController *)reader didScanResult:(NSString *)result  {      [self dismissViewControllerAnimated:YES completion:^{           NSLog(@"%@", result);      }];  }    - (void)readerDidCancel:(QRCodeReaderViewController *)reader  {      [self dismissViewControllerAnimated:YES completion:NULL];  }

项目主页:http://www.open-open.com/lib/view/home/1445843892351