Create a gist now

Instantly share code, notes, and snippets.

@yannickl /ZBarTest.h
Last active Dec 16, 2015

What would you like to do?
Here a little comparison between ZXing and ZBar in the point of view of the developer. The most important things is that ZXing is compiled using the Objective-C++ compiler (.mm) whereas ZBar is purely compile using the Objective-C compiler (.m).
#import <UIKit/UIKit.h>
#import "ZBarSDK.h"
@interface ZBarTest : NSObject <ZBarReaderDelegate>
@end
#import "ZBarTest.h"
@implementation ZBarTest
- (void)scan
{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:reader animated:YES];
}
#pragma mark -
#pragma mark ZBar Delegate Methods
- (void)imagePickerController:(UIImagePickerController *)reader didFinishPickingMediaWithInfo:(NSDictionary *) info
{
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
if (symbol) {
NSString *result = symbol.data;
NSLog(@"Result: %@", result);
}
}
@end
#import <UIKit/UIKit.h>
#import "ZXingWidgetController.h"
@interface ZXingTest : NSObject <ZXingDelegate>
@end
#import "ZXingTest.h"
#import "QRCodeReader.h"
@implementation ZXingTest
- (void)scan
{
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc] initWithObjects:qrcodeReader, nil];
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
widController.readers = readers;
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:widController animated:YES];
}
#pragma mark -
#pragma mark ZXing Delegate Methods
- (void)zxingController:(ZXingWidgetController *)controller didScanResult:(NSString *)result
{
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
NSLog(@"Result: %@", result);
}
- (void)zxingControllerDidCancel:(ZXingWidgetController *)controller
{
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment