Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading a Welcome Screen (Splash Screen) before TabBarController

In my TabBar based iPhone application, I would like to display a full screen welcome page (with some logs) before the actual application loads, How can I load a UIView from xib file as the welcome screen and then from there I can load my TabBar based application.

like image 355
shinto Joseph Avatar asked Aug 04 '26 04:08

shinto Joseph


2 Answers

The right way to do this would be to load your tab bar application normally, but use the presentModalViewController:animated: method of the tab bar controller to display a view controller over it (in application:didFinishLaunching:):

SplashScreenController *controller = [[SplashScreenController alloc] initWithNibNamed:nil bundle:nil];
[self.tabBarController presentModalViewController:controller animated:YES];
[controller release];

I'll usually put a "dismiss" button on the splash screen, but you could also do something like this:

[self.tabBarController performSelector:@selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:2.0];

which will present the view controller at launch and dismiss it after two seconds. Change the YESes to NOs to avoid the slide-up-from-the-bottom animation.

like image 110
Frank Schmitt Avatar answered Aug 06 '26 18:08

Frank Schmitt


I add a subView to the main window in the appDelegate:

LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
                                                                             bundle: nil];
[window addSubview: [loginController view]];

Then in the LoginViewController, when I'm ready to dismiss the View (to show YOUR tabController say) I do:

UIView *currentView = self.view;
UIView *theWindow = [currentView superview];

[currentView removeFromSuperview];

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
like image 43
mr-sk Avatar answered Aug 06 '26 16:08

mr-sk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!