1

I am programming an app for the iphone in Objective C in Xcode. What I am trying to do is to make a splash screen at the start of my app last for about 2 or 3 seconds, I have looked throughout the internet, but all of the tutorials on how to do this were outdated and did not work with the current versions of Xcode and Interface Builder. So I was wondering how would I use NSTimer to post an image for about 3 seconds and then change the alpha of the image to 0. By the way, I am wondering how to do this while using a Window Based Application preset. Any help would be greatly appreciated and an example would probably help as well.

Ryan S
  • 31
  • 1
  • My comment keeps on getting truncated so I deleted it. But @Ryan, you can try the suggestion from this thread: http://stackoverflow.com/questions/4497070/runtime-splash-screen-iphone – Perception Jul 08 '11 at 18:46

2 Answers2

3

Apple does not like seeing splashscreens. But if you're insisting, have you tried just setting a Default.png image? Just drag an image called Default.png into your App's "Resources" folder and your splashscreen will be shown at startup.

Info: The real purpose of Default.png is to make the UI appear in an "almost ready" state before the app is actually ready and that's what Apple intends you to use this for, but apps don't get rejected for using this function for their Splashscreens.

Pripyat
  • 2,937
  • 2
  • 35
  • 69
  • This will basically do what you want, but it won't fade. Still, it's the best way to go. – Daniel G. Wilson Jul 08 '11 at 18:13
  • Ive tried that, but using the default.png only displays the image for about a second and i am trying to get it to stay on for at least 2 seconds. Also, i don't really care about it fading, just staying on for at least 2 seconds. – Ryan S Jul 08 '11 at 18:37
  • 1
    Splash screens are a terrible idea - Why do you want to make your user wait before getting into your app? – Abizern Jul 08 '11 at 18:54
  • Splash screens are a great idea - imagine an app that requires time consuming set up, like half the games available, without one. They can serve a very useful function. – Michael Morrison Jul 26 '11 at 00:56
1

@David Schiefer is correct. For more info see the Apple Docs (scroll down to Application Launch Images).

But if you wanted to actually implement something regardless you can do as suggested and use the standard mechanism. Then in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

you could throw up the same image (your splash) in an imageview then use animation blocks like this.

[UIView animateWithDuration:0.5
                      delay:3
                    options:UIViewAnimationCurveLinear
                 animations:^{
                    myImageView.alpha = 0;
                 }
                 completion:^(BOOL finished){
                    [myImageView removeFromSuperview];
                 }];

If you want it every time the app is launched add to this instead

- (void)applicationDidBecomeActive:(UIApplication *)application
Paul.s
  • 38,494
  • 5
  • 70
  • 88