zxing/iphone/ScanTest/Classes/RootViewController.mm
smparkes@smparkes.net 439ff92bd9 Issue 479
Note, the audio no longer plays. I'm pretty sure this is because the widget is dismissed immediately
and the sound is released before it is played. I'm thinkng audio feedback should be done by the caller.


git-svn-id: https://zxing.googlecode.com/svn/trunk@1546 59b500cc-1b3d-0410-9834-0bbf25fbcc57
2010-08-17 21:18:56 +00:00

74 lines
1.7 KiB
Plaintext

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