iOS仿微信二維碼掃描:MQRCodeReaderViewController
iOS仿微信二維碼掃描:MQRCodeReaderViewController。這個項目基于 QRCodeReaderViewController
What did I modified?
I modified and expanded theQRCodeReaderView, make the interface become more like WeChat.
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];
} 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!