Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cyberserker

macrumors newbie
Original poster
Apr 17, 2009
6
0
France (Lyon)
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.

Thanks

Julien
 

johnnyjibbs

macrumors 68030
Sep 18, 2003
2,964
122
London, UK
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.
 

cyberserker

macrumors newbie
Original poster
Apr 17, 2009
6
0
France (Lyon)
@johnnyjibbs

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...

Julien
 

johnnyjibbs

macrumors 68030
Sep 18, 2003
2,964
122
London, UK
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:

Code:
[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:

Code:
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(splashScreenDidFadeOut)];

Code:
-(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.
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
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 >_<.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.