2010-05-12 11:24:18 -07:00
|
|
|
//
|
|
|
|
// RootViewController.m
|
|
|
|
// ScanTest
|
|
|
|
//
|
|
|
|
// Created by David Kavanagh on 5/10/10.
|
|
|
|
// Copyright __MyCompanyName__ 2010. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "RootViewController.h"
|
2010-06-15 15:01:04 -07:00
|
|
|
#import "QRCodeReader.h"
|
|
|
|
|
2010-06-19 09:58:19 -07:00
|
|
|
|
2010-05-30 04:40:09 -07:00
|
|
|
@interface RootViewController()
|
|
|
|
|
|
|
|
@end
|
2010-05-12 11:24:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
@implementation RootViewController
|
|
|
|
@synthesize resultsView;
|
2010-05-22 02:17:41 -07:00
|
|
|
@synthesize resultsToDisplay;
|
2010-05-12 11:24:18 -07:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark View lifecycle
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
2010-06-19 09:58:19 -07:00
|
|
|
[super viewDidLoad];
|
2010-08-17 14:18:56 -07:00
|
|
|
[self setTitle:@"ZXing"];
|
|
|
|
[resultsView setText:resultsToDisplay];
|
2010-06-19 09:58:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)scanPressed:(id)sender {
|
|
|
|
|
2010-05-30 04:40:09 -07:00
|
|
|
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
|
2010-06-15 15:01:04 -07:00
|
|
|
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
|
|
|
|
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
|
|
|
|
[qrcodeReader release];
|
|
|
|
widController.readers = readers;
|
|
|
|
[readers release];
|
2010-06-19 09:58:19 -07:00
|
|
|
NSBundle *mainBundle = [NSBundle mainBundle];
|
2010-08-17 14:18:56 -07:00
|
|
|
widController.soundToPlay =
|
|
|
|
[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO];
|
|
|
|
[self presentModalViewController:widController animated:YES];
|
2010-05-30 04:40:09 -07:00
|
|
|
[widController release];
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
2010-06-19 09:58:19 -07:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark ZXingDelegateMethods
|
2010-05-12 11:24:18 -07:00
|
|
|
|
2010-06-19 09:58:19 -07:00
|
|
|
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result {
|
2010-05-22 02:17:41 -07:00
|
|
|
self.resultsToDisplay = result;
|
2010-08-17 14:18:56 -07:00
|
|
|
if (self.isViewLoaded) {
|
|
|
|
[resultsView setText:resultsToDisplay];
|
|
|
|
[resultsView setNeedsDisplay];
|
|
|
|
}
|
|
|
|
[self dismissModalViewControllerAnimated:NO];
|
2010-05-22 02:17:41 -07:00
|
|
|
}
|
|
|
|
|
2010-06-19 09:58:19 -07:00
|
|
|
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller {
|
|
|
|
[self dismissModalViewControllerAnimated:YES];
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidUnload {
|
2010-08-17 14:18:56 -07:00
|
|
|
self.resultsView = nil;
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc {
|
2010-05-22 02:17:41 -07:00
|
|
|
[resultsView release];
|
|
|
|
[resultsToDisplay release];
|
2010-06-19 09:58:19 -07:00
|
|
|
[super dealloc];
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|