2 // RootViewController.m
5 // Created by David Kavanagh on 5/10/10.
6 // Copyright __MyCompanyName__ 2010. All rights reserved.
9 #import "RootViewController.h"
12 @implementation RootViewController
13 @synthesize resultsView;
16 #pragma mark View lifecycle
20 [self setTitle:@"ZXing"];
21 scanController = [[ZXingWidgetController alloc] initWithDelegate:self];
22 NSBundle *mainBundle = [NSBundle mainBundle];
23 [scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
26 - (IBAction)scanPressed:(id)sender {
27 [self presentModalViewController:scanController animated:YES];
28 // [self.navigationController pushViewController:scanController animated:true];
32 - (void)viewWillAppear:(BOOL)animated {
33 [super viewWillAppear:animated];
37 - (void)viewDidAppear:(BOOL)animated {
38 [super viewDidAppear:animated];
42 - (void)viewWillDisappear:(BOOL)animated {
43 [super viewWillDisappear:animated];
47 - (void)viewDidDisappear:(BOOL)animated {
48 [super viewDidDisappear:animated];
53 // Override to allow orientations other than the default portrait orientation.
54 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
55 // Return YES for supported orientations.
56 return (interfaceOrientation == UIInterfaceOrientationPortrait);
60 #pragma mark Memory management
62 - (void)scanResult:(NSString *)result {
63 [resultsView setText:result];
64 [self dismissModalViewControllerAnimated:true];
68 [self dismissModalViewControllerAnimated:true];
72 #pragma mark Memory management
74 - (void)didReceiveMemoryWarning {
75 // Releases the view if it doesn't have a superview.
76 [super didReceiveMemoryWarning];
78 // Relinquish ownership any cached data, images, etc that aren't in use.
81 - (void)viewDidUnload {
82 // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
83 // For example: self.myOutlet = nil;
88 [scanController dealloc];