48516266bb1a0a75e503b125046234be931dae10
[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
11
12 @implementation RootViewController
13 @synthesize resultsView;
14
15 #pragma mark -
16 #pragma mark View lifecycle
17
18 - (void)viewDidLoad {
19     [super viewDidLoad];
20         [self setTitle:@"ZXing"];
21         scanController = [ZXingWidgetController alloc];
22         [scanController setOneDMode:false];
23         [scanController setShowCancel:true];
24         scanController = [scanController initWithDelegate:self];
25         NSBundle *mainBundle = [NSBundle mainBundle];
26         [scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
27 }
28
29 - (IBAction)scanPressed:(id)sender {
30         [self presentModalViewController:scanController animated:YES];
31 //      [self.navigationController pushViewController:scanController animated:true];
32 }
33
34 /*
35 - (void)viewWillAppear:(BOOL)animated {
36     [super viewWillAppear:animated];
37 }
38 */
39 /*
40 - (void)viewDidAppear:(BOOL)animated {
41     [super viewDidAppear:animated];
42 }
43 */
44 /*
45 - (void)viewWillDisappear:(BOOL)animated {
46         [super viewWillDisappear:animated];
47 }
48 */
49 /*
50 - (void)viewDidDisappear:(BOOL)animated {
51         [super viewDidDisappear:animated];
52 }
53 */
54
55 /*
56  // Override to allow orientations other than the default portrait orientation.
57 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
58         // Return YES for supported orientations.
59         return (interfaceOrientation == UIInterfaceOrientationPortrait);
60 }
61  */
62
63 #pragma mark Memory management
64
65 - (void)scanResult:(NSString *)result {
66         [resultsView setText:result];
67         [self dismissModalViewControllerAnimated:true];
68 }
69
70 - (void)cancelled {
71         [self dismissModalViewControllerAnimated:true];
72 }
73
74 #pragma mark -
75 #pragma mark Memory management
76
77 - (void)didReceiveMemoryWarning {
78     // Releases the view if it doesn't have a superview.
79     [super didReceiveMemoryWarning];
80     
81     // Relinquish ownership any cached data, images, etc that aren't in use.
82 }
83
84 - (void)viewDidUnload {
85     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
86     // For example: self.myOutlet = nil;
87 }
88
89
90 - (void)dealloc {
91         [scanController dealloc];
92     [super dealloc];
93 }
94
95
96 @end
97