Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a splash screen in iOS

I'm quite a newbie in Cocoa, Objective-C and iOS development.

I'd like to implement a View that is just a splash screen and only last for a short time before routing to the main view. Do you have any idea on how I should implement that ? Any tutorials or code samples ? I have some with multiple views, but none with a timer to redirect to another one after a few seconds like I want to do.

like image 369
Patrice Cote Avatar asked Feb 12 '11 21:02

Patrice Cote


People also ask

Does iOS have splash screen?

Forget about adding images for splash screen (launch screen) with different sizes. Your app will be much bigger for no reason. You can use smarter way how to achieve awesome splash screen just with one size of the image.

What is splash screen in iOS?

The main purpose of the iOS launch/splash screen is to let the user know that the app is loading and the launch screen will disappear quickly once our application loading is completed.

How do I create a splash screen in Xcode?

Adding splash screen on iOSStart by opening the file ios/app-name. xcodeproj in Xcode. Then, drag the file BootSplash. storyboard under the Project directory in the Xcode file manager on the left side of the Xcode from the path ios/app-name/ directory.


2 Answers

See App Launch (Default) Images under the iOS Application Programming Guide.

It should also be noted Apple advised NOT abusing the launch image as a splash screen. Apple HIG

like image 163
Espresso Avatar answered Oct 15 '22 10:10

Espresso


You can easily implement your view on top of the main view but in your appDelegate. For example, if you want a splash image that fades out to the main view: (or a default image that seems to fade out: just put the same image on the splash screen and the default screen). This gives you also the right orientation as long as it is the main view's.

Just add it in your application:(UIApplication *)application didFinishLaunchingWithOptions: method:

 UIImageView*imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"your_default_image_or_another.png"]]; [[firstViewController view] addSubview:imageView]; [[firstViewController view] bringSubviewToFront:imageView];  // as usual [self.window makeKeyAndVisible];  //now fade out splash image [UIView transitionWithView:self.window duration:1.0f options:UIViewAnimationOptionTransitionNone animations:^(void){imageView.alpha=0.0f;} completion:^(BOOL finished){[imageView removeFromSuperview];}]; 
like image 33
NightCoder Avatar answered Oct 15 '22 09:10

NightCoder