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];
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]];
29 - (IBAction)scanPressed:(id)sender {
30 [self presentModalViewController:scanController animated:YES];
31 // [self.navigationController pushViewController:scanController animated:true];
35 - (void)viewWillAppear:(BOOL)animated {
36 [super viewWillAppear:animated];
40 - (void)viewDidAppear:(BOOL)animated {
41 [super viewDidAppear:animated];
45 - (void)viewWillDisappear:(BOOL)animated {
46 [super viewWillDisappear:animated];
50 - (void)viewDidDisappear:(BOOL)animated {
51 [super viewDidDisappear:animated];
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);
63 #pragma mark Memory management
65 - (void)scanResult:(NSString *)result {
66 [resultsView setText:result];
67 [self dismissModalViewControllerAnimated:true];
71 [self dismissModalViewControllerAnimated:true];
75 #pragma mark Memory management
77 - (void)didReceiveMemoryWarning {
78 // Releases the view if it doesn't have a superview.
79 [super didReceiveMemoryWarning];
81 // Relinquish ownership any cached data, images, etc that aren't in use.
84 - (void)viewDidUnload {
85 // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
86 // For example: self.myOutlet = nil;
91 [scanController dealloc];