From e99dd51de964a58d215674336a299759886c8cd6 Mon Sep 17 00:00:00 2001 From: dkavanagh Date: Thu, 13 May 2010 16:05:02 +0000 Subject: [PATCH] call widget delegate after 1 sec delay. this gives ui time to show points and user time to view them. git-svn-id: https://zxing.googlecode.com/svn/trunk@1360 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- iphone/ZXingWidget/ZXingWidgetController.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/iphone/ZXingWidget/ZXingWidgetController.m b/iphone/ZXingWidget/ZXingWidgetController.m index 754c6e7bf..d3560afe9 100755 --- a/iphone/ZXingWidget/ZXingWidgetController.m +++ b/iphone/ZXingWidget/ZXingWidgetController.m @@ -54,6 +54,12 @@ CGImageRef UIGetScreenImage(); return self; } +- (void)dealloc { + AudioServicesDisposeSystemSoundID(beepSound); + [overlayView dealloc]; + [super dealloc]; +} + - (void)cancelled { NSLog(@"cancelled called in ZXingWidgetController"); wasCancelled = true; @@ -79,6 +85,15 @@ CGImageRef UIGetScreenImage(); return false; } +- (void)viewDidLoad { + [super viewDidLoad]; + NSBundle *mainBundle = [NSBundle mainBundle]; + OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"caf"] isDirectory:NO], &beepSound); + if (error != kAudioServicesNoError) { + NSLog(@"Problem loading nearSound.caf"); + } +} + - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [overlayView setPoints:nil]; @@ -119,7 +134,6 @@ CGImageRef UIGetScreenImage(); NSLog(@"in presentResultForString()"); self.result = [ResultParser parsedResultForString:resultString]; AudioServicesPlaySystemSound(beepSound); - // self.actions = self.result.actions; #ifdef DEBUG NSLog(@"result string = %@", resultString); NSLog(@"result has %d actions", actions ? 0 : actions.count); @@ -140,7 +154,7 @@ CGImageRef UIGetScreenImage(); NSLog(@"decoded image!!"); [self presentResultPoints:[twoDResult points] forImage:image usingSubset:subset]; // now, in a selector, call the delegate to give this overlay time to show the points - [self performSelectorOnMainThread:@selector(alertDelegate:) withObject:[[twoDResult text] copy] waitUntilDone:false]; + [self performSelector:@selector(alertDelegate:) withObject:[[twoDResult text] copy] afterDelay:1.0]; decoder.delegate = nil; [decoder release]; }