RSBarcodes 0.1.4

RSBarcodes 0.1.4

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2015年10月

R0CKSTAR维护。



  • R0CKSTAR和张玺

Total views Views in the last 24 hours

RSBarcodes允许您使用iOS7引入的元数据扫描功能扫描1D和2D条码,并生成同一系列的条码图像进行显示和分享。MacMannes的PR已被合并,使其代码生成器部分功能在iOS5.1及以上版本上运行。

当前状态

条码扫描器

Multiple corners and border rectangles display view -- Done
Manually changing focus point -- Done
Focus mark drawing -- Done

条码生成器

"org.gs1.UPC-E", -- Done
"org.iso.Code39", -- Done
"org.iso.Code39Mod43", -- Done
"org.gs1.EAN-13", -- Done by 张玺 (http://zhangxi.me)
"org.gs1.EAN-8", -- Done by 张玺 (http://zhangxi.me)
"com.intermec.Code93", -- Done
"org.iso.Code128", -- Done
"org.iso.PDF417", -- Done
"org.iso.QRCode", -- Done
"org.iso.Aztec", -- Done
"org.ansi.Interleaved2of5", -- Done
"org.gs1.ITF14", -- Done
// --------------------
Extended Code 39, -- Done
ISBN13, -- Done
ISSN13, -- Done
ITF14, -- Done

Code display view -- Done

安装

CocoaPods 是安装RSBarcodes的推荐方法。

只需将以下行添加到您的 Podfile

pod 'RSBarcodes', '~> 0.1.3'

或者您可以使用 RSBarcodes框架 而无需导入所有头部文件。

只需导入这些框架:

RSBarcodes.framework (它在此项目的产品文件夹下) :)
AVFoundation.framework
CoreImage.framework
CoreGraphics.framework

当您使用框架时,必须导入如下所示的头部:

#import <RSBarcodes/aHeader.h>

RSCodeView.hRSCodeGen.h 已导入到 RSBarcodes.h 中,所以您可以直接使用。

#import <RSBarcodes/RSBarcodes.h>

感谢 g8production www.g8production.com github 提供这些。

使用

条码扫描器

选项1

从代码创建 RSScannerViewController 并显示它。使用回调块处理条码。

(id)initWithCornerView:(BOOL)showCornerView controlView:(BOOL)showControlsView barcodesHandler:(RSBarcodesHandler)barcodesHandler;
(id)initWithCornerView:(BOOL)showCornerView controlView:(BOOL)showControlsView barcodesHandler:(RSBarcodesHandler)barcodesHandler preferredCameraPosition:(AVCaptureDevicePosition)cameraDevicePosition;

您可以使用以下方式为按钮添加边框:[scanner setIsButtonBordersVisible:YES]; 您可以使用 [scanner setStopOnFirst:YES]; 在第一个有效条码后自动停止处理;之后,您可以选择取消托管它,或者使用 [scanner __startRunning] 重新启动它;

可能设备位置:AVCaptureDevicePositionBack, AVCaptureDevicePositionFront

RSScannerViewController *scanner = [[RSScannerViewController alloc] initWithCornerView:YES
                                                                           controlView:YES
                                                                           barcodesHandler:^(NSArray *barcodeObjects) {
                                                                       }
                                                               preferredCameraPosition:AVCaptureDevicePositionBack];
[self presentViewController:scanner animated:true completion:nil];

选项2

在Storyboard中将UIViewController放置,并设置基于RSScannerViewController的自定义类。如果您想使用角落视图(用于显示条码角落和边框),可以在视图控制器视图中放置一个UIView,并将其自定义类设置为RSCornersView,然后将highlightView链接到它,确保视图的大小与视图控制器视图的大小相同。

在基于RSScannerViewController的类中实现您自己的处理程序。

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        __weak typeof(self) weakSelf = self;
        self.barcodesHandler = ^(NSArray *barcodeObjects) {
        };
        self.tapGestureHandler = ^(CGPoint tapPoint) {
        });
    }
    return self;
}

条码生成器

RSCodeGen.h导入到您的源文件中,并使用CodeGen生成条码图像。RSBarcodes提供两种方法。

@protocol RSCodeGenerator <NSObject>

- (UIImage *)genCodeWithMachineReadableCodeObject:(AVMetadataMachineReadableCodeObject *)machineReadableCodeObject;

- (UIImage *)genCodeWithContents:(NSString *)contents machineReadableCodeObjectType:(NSString *)type;

@end

以下是示例,生成的图像可以与RSCodeViewUIImageView一起使用。

[CodeGen genCodeWithContents:<#(NSString *)#> machineReadableCodeObjectType:<#(NSString *)#>] // Types are coming from AVMetadataObject.h and RSCodeGen.h

或者

[CodeGen genCodeWithMachineReadableCodeObject:<#(AVMetadataMachineReadableCodeObject *)#>]

许可

The MIT License (MIT)

Copyright (c) 2012-2014 P.D.Q.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge