2 // RootViewController.m
5 // Created by David Kavanagh on 5/10/10.
6 // Copyright __MyCompanyName__ 2010. All rights reserved.
9 #import "RootViewController.h"
10 @interface RootViewController()
11 @property (nonatomic,retain) ZXingWidgetController *scanController;
16 @implementation RootViewController
17 @synthesize resultsView;
18 @synthesize resultsToDisplay;
19 @synthesize scanController;
21 #pragma mark View lifecycle
25 [self setTitle:@"ZXing"];
27 ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
28 self.scanController = widController;
29 [widController release];
30 NSBundle *mainBundle = [NSBundle mainBundle];
31 [scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
35 - (IBAction)scanPressed:(id)sender {
36 //UIImagePickerController *picker = [[UIImagePickerController alloc] init];
37 [self presentModalViewController:scanController
39 // [self.navigationController pushViewController:scanController animated:true];
43 - (void)viewWillAppear:(BOOL)animated {
44 [super viewWillAppear:animated];
48 - (void)viewDidAppear:(BOOL)animated {
49 [super viewDidAppear:animated];
53 - (void)viewWillDisappear:(BOOL)animated {
54 [super viewWillDisappear:animated];
58 - (void)viewDidDisappear:(BOOL)animated {
59 [super viewDidDisappear:animated];
64 // Override to allow orientations other than the default portrait orientation.
65 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
66 // Return YES for supported orientations.
67 return (interfaceOrientation == UIInterfaceOrientationPortrait);
71 #pragma mark Memory management
73 - (void)scanResult:(NSString *)result {
74 //[self.resultsView setText:result];
75 [self dismissModalViewControllerAnimated:YES];
76 self.resultsToDisplay = result;
79 - (void)viewWillAppear:(BOOL)animated {
82 [resultsView setText:resultsToDisplay];
83 [resultsView setNeedsDisplay];
88 [self dismissModalViewControllerAnimated:YES];
92 #pragma mark Memory management
94 - (void)didReceiveMemoryWarning {
95 // Releases the view if it doesn't have a superview.
96 [super didReceiveMemoryWarning];
98 // Relinquish ownership any cached data, images, etc that aren't in use.
101 - (void)viewDidUnload {
102 // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
103 // For example: self.myOutlet = nil;
108 [resultsView release];
109 [scanController release];
110 [resultsToDisplay release];