How to initialize a custom splash screen before loading a tab bar controller into a storyboard?

I have an application in which I have a custom view controller and then a tab bar controller. Currently, I have installed the tab bar controller as the initial view controller. But I want the popup view controller to appear first, and then the tab bar controller. Any idea how to do this?

+4
source share
6 answers

Instead of a PushView controller Use presentViewController Try this code

override func viewDidLoad() {
    super.viewDidLoad()

   _ = NSTimer.scheduledTimerWithTimeInterval(2.1, target: self, selector: #selector(Splash.someSelector), userInfo: nil, repeats: false)
    // Do any additional setup after loading the view.
}

func someSelector() {
    let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let vc : TabBarCotroller = storyboard.instantiateViewControllerWithIdentifier("TabBarCotroller") as! TabBarCotroller

    let navigationController = UINavigationController(rootViewController: vc)
    self.presentViewController(navigationController, animated: true, completion: nil)
}
+4
source

, Initial view controller. tabbar navigation controller.

let tabBar = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBar, animated: true)
+4

@Amelia frensheo - :

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
appDelegate.window.rootViewController = [[SplashViewCtr alloc] init];
appDelegate.window.rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[appDelegate.window makeKeyAndVisible]; 
UITabBarController *rootViewCtrl = [[UITabBarController alloc] init];

[appDelegate.window.rootViewController presentViewController:rootViewCtrl animated:YES completion:nil];

[UIView transitionFromView:window.rootViewController.view toView:rootViewCtrl.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
        appDelegate.window.rootViewController = rootViewCtrl.view;
 }];
+1

5 , tabcontroller viewWillAppear.

tabcontroller, rootviewcontroller.

0

rootViewController, modalTransitionStyle = UIModalTransitionStyleCrossDissolve; rootViewController tabview rootViewController

0

, ,

First of all, in the storyboard, create a custom class view controller as the initial view controller. And after that, click the panel controller on the current navigation controller.

let tabBarVC = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController
tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBarVC, animated: true)

Try this, it can help you.

0
source

All Articles