Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding A Visual Timer To A View, iPhone
    primarykey
    data
    text
    <p>I have a view (splash screen) which displays for two minutes:</p> <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application { [viewController showSplash]; } - (void)showSplash // Show splash screen { UIViewController *modalViewController = [[UIViewController alloc] init]; modalViewController.view = modelView; [self presentModalViewController:modalViewController animated:NO]; [self performSelector:@selector(hideSplash) withObject:nil afterDelay:120.0]; } </code></pre> <p>I want to add a timer which counts down from 2 minutes to zero to this splash screen.</p> <p>I imagine I will need to create another view containing the timer. Is this correct? How would I do this and add it to the splash screen, and how would I make the numbers in the timer be displayed on screen in white?</p> <p>I know two minutes is a very long time to display a splash screen for... but I am just experimenting with various things, there are other things going on for the two minutes!</p> <p>Many thanks,</p> <p>Stu</p> <p>Edit // Ok I now have this:</p> <p>(.h)</p> <pre><code>NSTimer *timer5; UILabel *countDown; float timeOnSplash; </code></pre> <p>(.m)</p> <pre><code>- (void) updateLabel:(NSTimer*)theTimer { float timeOnSplash = timeOnSplash - 1; countDown.text = [NSString stringWithFormat:@"%02d:%02d", timeOnSplash]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { timer5 = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES]; countDown.text = [NSString stringWithFormat:@"%02d:%02d", timeOnSplash]; } </code></pre> <p>I get the following uncaught exception when I run the code:</p> <p>'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key countDown.'</p> <p>Any ideas?</p> <p>Edit 2 // Working now, for an excellent solution see TechZen's answer. </p> <p>Many thanks to all!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload