Skip to content

iOS 二维码扫描控件, UI 做了优化, 仿造微信, 直接拖进项目就可使用, 支持 CocoaPods 安装. WeChat-like QRCode reader, drop-in version, support for CocoaPods

License

Notifications You must be signed in to change notification settings

zhengjinghua/MQRCodeReaderViewController

Repository files navigation


 创造不息,交付不止


English Guide

说明

MQRCodeReaderViewController 基于 QRCodeReaderViewController 封装的二维码扫描控件, 仿照微信的二维码扫描器风格美化了界面, 直接加入你的项目中就能使用, 无需再次定制 UI.

Made with ❤️ by The EST Group - We design and build: the Future!

screenshot

安装

CocoaPods 安装

将下面代码复制进你的 Podfile 文件中

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

手工安装

下载 此项目, 然后将该项目里的 QRCodeReaderViewController 文件夹里的所有文件复制进你的项目中, 然后在需要调用此项目的地方引入

#import "QRCodeReaderViewController.h"

使用

支持以下两种方法调用, 选其一, 代码见下面:

  • 使用 Delegate 方法调用;
  • 使用 Block 方法调用;
- (IBAction)scanAction:(id)sender
{
	NSArray *types = @[AVMetadataObjectTypeQRCode];
  	_reader        = [QRCodeReaderViewController readerWithMetadataObjectTypes:types];
  
  	// 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];
}

协议

MQRCodeReaderViewController 被许可在 MIT 协议下使用. 查阅 LICENSE 文件来获得更多信息.

README (ENGLISH)

Description

This projecd baesd on QRCodeReaderViewController, a little UI ajustment from QRCodeReaderView, make the interface more like WeChat.

Made with ❤️ by The EST Group - We design and build: the Future!

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 the QRCodeReaderViewController folder 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];
  
  	// 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];
}

License

StitchingImage is available under the MIT license. See the LICENSE file for more info.


About

iOS 二维码扫描控件, UI 做了优化, 仿造微信, 直接拖进项目就可使用, 支持 CocoaPods 安装. WeChat-like QRCode reader, drop-in version, support for CocoaPods

Resources

License

Stars

Watchers

Forks

Packages

No packages published