2 // RootViewController.m
5 // Created by David Kavanagh on 5/10/10.
6 // Copyright __MyCompanyName__ 2010. All rights reserved.
9 #import "RootViewController.h"
10 #import "QRCodeReader.h"
12 @interface RootViewController()
13 @property (nonatomic,retain) ZXingWidgetController *scanController;
18 @implementation RootViewController
19 @synthesize resultsView;
20 @synthesize resultsToDisplay;
21 @synthesize scanController;
23 #pragma mark View lifecycle
27 [self setTitle:@"ZXing"];
29 ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
30 QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
31 NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
32 [qrcodeReader release];
33 widController.readers = readers;
36 self.scanController = widController;
37 [widController release];
38 NSBundle *mainBundle = [NSBundle mainBundle];
39 [scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
43 - (IBAction)scanPressed:(id)sender {
44 //UIImagePickerController *picker = [[UIImagePickerController alloc] init];
45 [self presentModalViewController:scanController
47 // [self.navigationController pushViewController:scanController animated:true];
51 - (void)viewWillAppear:(BOOL)animated {
52 [super viewWillAppear:animated];
56 - (void)viewDidAppear:(BOOL)animated {
57 [super viewDidAppear:animated];
61 - (void)viewWillDisappear:(BOOL)animated {
62 [super viewWillDisappear:animated];
66 - (void)viewDidDisappear:(BOOL)animated {
67 [super viewDidDisappear:animated];
72 // Override to allow orientations other than the default portrait orientation.
73 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
74 // Return YES for supported orientations.
75 return (interfaceOrientation == UIInterfaceOrientationPortrait);
79 #pragma mark Memory management
81 - (void)scanResult:(NSString *)result {
82 //[self.resultsView setText:result];
83 [self dismissModalViewControllerAnimated:NO];
84 self.resultsToDisplay = result;
87 - (void)viewWillAppear:(BOOL)animated {
90 [resultsView setText:resultsToDisplay];
91 [resultsView setNeedsDisplay];
96 [self dismissModalViewControllerAnimated:YES];
100 #pragma mark Memory management
102 - (void)didReceiveMemoryWarning {
103 // Releases the view if it doesn't have a superview.
104 [super didReceiveMemoryWarning];
106 // Relinquish ownership any cached data, images, etc that aren't in use.
109 - (void)viewDidUnload {
110 // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
111 // For example: self.myOutlet = nil;
116 [resultsView release];
117 [scanController release];
118 [resultsToDisplay release];