[iphone] added known issues in README when including ZXingWidget into your project...
[zxing.git] / iphone / ScanTest / Classes / RootViewController.m
1 //
2 //  RootViewController.m
3 //  ScanTest
4 //
5 //  Created by David Kavanagh on 5/10/10.
6 //  Copyright __MyCompanyName__ 2010. All rights reserved.
7 //
8
9 #import "RootViewController.h"
10 @interface RootViewController()
11 @property (nonatomic,retain) ZXingWidgetController *scanController;
12
13 @end
14
15
16 @implementation RootViewController
17 @synthesize resultsView;
18 @synthesize resultsToDisplay;
19 @synthesize scanController;
20 #pragma mark -
21 #pragma mark View lifecycle
22
23 - (void)viewDidLoad {
24     [super viewDidLoad];
25         [self setTitle:@"ZXing"];
26   
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]];
32    
33 }
34
35 - (IBAction)scanPressed:(id)sender {
36   //UIImagePickerController *picker = [[UIImagePickerController alloc] init];
37         [self presentModalViewController:scanController
38                           animated:NO];
39 //      [self.navigationController pushViewController:scanController animated:true];
40 }
41
42 /*
43 - (void)viewWillAppear:(BOOL)animated {
44     [super viewWillAppear:animated];
45 }
46 */
47 /*
48 - (void)viewDidAppear:(BOOL)animated {
49     [super viewDidAppear:animated];
50 }
51 */
52 /*
53 - (void)viewWillDisappear:(BOOL)animated {
54         [super viewWillDisappear:animated];
55 }
56 */
57 /*
58 - (void)viewDidDisappear:(BOOL)animated {
59         [super viewDidDisappear:animated];
60 }
61 */
62
63 /*
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);
68 }
69  */
70
71 #pragma mark Memory management
72
73 - (void)scanResult:(NSString *)result {
74         //[self.resultsView setText:result];
75         [self dismissModalViewControllerAnimated:YES];
76   self.resultsToDisplay = result;
77 }
78
79 - (void)viewWillAppear:(BOOL)animated {
80   if (resultsToDisplay)
81   {
82     [resultsView setText:resultsToDisplay];
83     [resultsView setNeedsDisplay];
84   }
85 }
86
87 - (void)cancelled {
88         [self dismissModalViewControllerAnimated:YES];
89 }
90
91 #pragma mark -
92 #pragma mark Memory management
93
94 - (void)didReceiveMemoryWarning {
95     // Releases the view if it doesn't have a superview.
96     [super didReceiveMemoryWarning];
97     
98     // Relinquish ownership any cached data, images, etc that aren't in use.
99 }
100
101 - (void)viewDidUnload {
102     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
103     // For example: self.myOutlet = nil;
104 }
105
106
107 - (void)dealloc {
108   [resultsView release];
109         [scanController release];
110   [resultsToDisplay release];
111     [super dealloc];
112 }
113
114
115 @end
116