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.
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.
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.
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.
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
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];}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With