1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

HowTo display full screen image at launch?

Discussion in 'iPhone/iPad Programming' started by cyberserker, Apr 17, 2009.

  1. macrumors newbie

    I just would like to display a transient animated image when my application starts.

    The idea is showing the company logo which after several seconds slowly disappears to display the mainView.


  2. macrumors 68030


    Start by putting in a startup image. Create a screenshot of the starting screen you wish to show, then call it default.png and stick it in your root bundle.

    The startup image can only be static but you could insert a temporary view controller that loads on application startup which initially contains the same image but then fades it off or whatever you want to do. Then load up your main application views after that.
  3. macrumors newbie


    You're right, it's exactly what I want to do.
    The question is: how to set the view containing the image for shading after, let say, 5 seconds?

    I only found some things like UIViewAnimationTransitionFlipFromRight...

  4. macrumors 68030


    Not exactly sure what you mean but if you want you splash screen to fade off into your main view, you could set it up as a full screen view in your main view controller and then simply fade out the alpha on it to zero, so that you get a nice crossfade effect.

    To do this, you could set up you main view, with the splash screen overlayed on top (so that it covers the main view until it fades out).

    Then it's just a case of some simple fading using Core Animation:

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];  // this would cause the crossfade to take 1 second
    [splashScreenView setAlpha:0.0];
    [UIView commitAnimations];
    Then you could stick this piece of code in the viewDidAppear method (but have a condition so that it only runs once per application launch).

    You should perhaps also add the following 2 calls inside the animation block (before commitAnimations) to give yourself a chance to clear up memory afterwards:

    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(splashScreenDidFadeOut)];
    -(void) splashScreenDidFadeOut {
       // insert code here to get a pointer to splash screen object or use instance variable
       [splashScreenView removeFromSuperview];
    If you want the splash screen to stay on screen a little longer, you could implement a timer to wait a little while (see Apple's documentation on NSTimer), or use the performSelectorAfterDelay: method to delay it.
  5. macrumors 68000

    I don't think it's possible to time it exactly right because the start up image doesn't display for a set amount of time. It can take from a second to a few seconds depending on the person's iPhone in whether it's currently lagging.

    But if you wanted to wait five seconds AFTER the default image is shown...

    You'd use a UIView animation block. Set the delay to five seconds and set the duration the amount of time you want it to take in order to fade.

    Then set the alpha of the image as zero in the block.

    It should start fading after the number of seconds that you specified and take the number of seconds you specified to fade the thing.

    EDIT: Or what johnny said above...must have replied while I was typing mine >_<.
  6. macrumors newbie

    Thanks a lot for your help.

    I will try it this WeekEnd.

Share This Page