2010-05-12 11:24:18 -07:00
|
|
|
//
|
|
|
|
// RootViewController.m
|
|
|
|
// ScanTest
|
|
|
|
//
|
|
|
|
// Created by David Kavanagh on 5/10/10.
|
|
|
|
// Copyright __MyCompanyName__ 2010. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "RootViewController.h"
|
2010-05-30 04:40:09 -07:00
|
|
|
@interface RootViewController()
|
|
|
|
@property (nonatomic,retain) ZXingWidgetController *scanController;
|
|
|
|
|
|
|
|
@end
|
2010-05-12 11:24:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
@implementation RootViewController
|
|
|
|
@synthesize resultsView;
|
2010-05-22 02:17:41 -07:00
|
|
|
@synthesize resultsToDisplay;
|
2010-05-30 04:40:09 -07:00
|
|
|
@synthesize scanController;
|
2010-05-12 11:24:18 -07:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark View lifecycle
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
[self setTitle:@"ZXing"];
|
2010-05-29 04:31:41 -07:00
|
|
|
|
2010-05-30 04:40:09 -07:00
|
|
|
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
|
|
|
|
self.scanController = widController;
|
|
|
|
[widController release];
|
2010-05-13 10:34:36 -07:00
|
|
|
NSBundle *mainBundle = [NSBundle mainBundle];
|
|
|
|
[scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
|
2010-05-29 04:31:41 -07:00
|
|
|
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)scanPressed:(id)sender {
|
2010-05-29 04:31:41 -07:00
|
|
|
//UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
|
|
[self presentModalViewController:scanController
|
|
|
|
animated:YES];
|
2010-05-12 11:24:18 -07:00
|
|
|
// [self.navigationController pushViewController:scanController animated:true];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated {
|
|
|
|
[super viewDidDisappear:animated];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
// Override to allow orientations other than the default portrait orientation.
|
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
|
|
// Return YES for supported orientations.
|
|
|
|
return (interfaceOrientation == UIInterfaceOrientationPortrait);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma mark Memory management
|
|
|
|
|
2010-05-13 07:11:50 -07:00
|
|
|
- (void)scanResult:(NSString *)result {
|
2010-05-22 02:17:41 -07:00
|
|
|
//[self.resultsView setText:result];
|
2010-05-29 04:31:41 -07:00
|
|
|
[self dismissModalViewControllerAnimated:YES];
|
2010-05-22 02:17:41 -07:00
|
|
|
self.resultsToDisplay = result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
if (resultsToDisplay)
|
|
|
|
{
|
|
|
|
[resultsView setText:resultsToDisplay];
|
|
|
|
[resultsView setNeedsDisplay];
|
|
|
|
}
|
|
|
|
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)cancelled {
|
2010-05-29 04:31:41 -07:00
|
|
|
[self dismissModalViewControllerAnimated:YES];
|
2010-05-12 11:24:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Memory management
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
// Releases the view if it doesn't have a superview.
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
|
|
|
|
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidUnload {
|
|
|
|
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
|
|
|
|
// For example: self.myOutlet = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)dealloc {
|
2010-05-22 02:17:41 -07:00
|
|
|
[resultsView release];
|
|
|
|
[scanController release];
|
|
|
|
[resultsToDisplay release];
|
2010-05-12 11:24:18 -07:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|