From b4be0c5921f2edc31ea3f92d57ff52e4a16518d8 Mon Sep 17 00:00:00 2001 From: Philippe Casgrain Date: Mon, 13 Jul 2009 12:48:07 +0800 Subject: [PATCH] Fix for ticket #3: Better end-of-talk display. We remove the CounterView when the timer has expired on the last slide. Signed-off-by: Jonathan 'Wolf' Rentzsch --- BlitzPDFView.h | 1 + BlitzPDFView.m | 12 ++++++++---- MyDocument.m | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BlitzPDFView.h b/BlitzPDFView.h index 882a7db..a65fcde 100644 --- a/BlitzPDFView.h +++ b/BlitzPDFView.h @@ -11,6 +11,7 @@ @property uint16_t secondsElapsed; +- (void)atLastPage; - (IBAction)updateSecondsElapsed:(id)sender; @end diff --git a/BlitzPDFView.m b/BlitzPDFView.m index bd9349c..fe0cc40 100644 --- a/BlitzPDFView.m +++ b/BlitzPDFView.m @@ -163,9 +163,8 @@ - (void)drawPagePost:(PDFPage*)page { [counterView setNeedsDisplay: YES]; } -- (void)dealloc -{ - [counterView release]; +- (void)dealloc { + [self atLastPage]; [super dealloc]; } @@ -175,7 +174,12 @@ - (uint16_t) secondsElapsed { - (void)setSecondsElapsed:(uint16_t)secs { secondsElapsed = secs; - counterView.secondsElapsed = secs; + counterView.secondsElapsed = secs; +} + +- (void)atLastPage { + [[counterView animator] removeFromSuperview]; + counterView = nil; } - (IBAction)updateSecondsElapsed:(id)sender { diff --git a/MyDocument.m b/MyDocument.m index 98f1e7f..c2c284e 100644 --- a/MyDocument.m +++ b/MyDocument.m @@ -52,7 +52,13 @@ - (BOOL)readFromURL:(NSURL *)initWithURL ofType:(NSString *)typeName error:(NSEr - (void)updateElapsedTimer:(NSTimer*)timer_ { if (self.pdfView.secondsElapsed != 0 && (self.pdfView.secondsElapsed % 15 == 0)) { - [self.pdfView goToNextPage:nil]; + if ([self.pdfView canGoToNextPage]) { + [self.pdfView goToNextPage:nil]; + } + else { + [self.pdfView atLastPage]; + [timer_ invalidate]; + } } self.pdfView.secondsElapsed += 1; [self.pdfView setNeedsDisplay:YES];