From: dkavanagh Date: Thu, 13 May 2010 16:05:02 +0000 (+0000) Subject: call widget delegate after 1 sec delay. this gives ui time to show points and user... X-Git-Url: http://git.rot13.org/?p=zxing.git;a=commitdiff_plain;h=89260cba5ddbb877db74ff501ea01e9417dca8fa call widget delegate after 1 sec delay. this gives ui time to show points and user time to view them. git-svn-id: http://zxing.googlecode.com/svn/trunk@1360 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- diff --git a/iphone/ZXingWidget/ZXingWidgetController.m b/iphone/ZXingWidget/ZXingWidgetController.m index 754c6e7b..d3560afe 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]; }