Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialise a custom splash screen before loading tab bar controller in storyboard?

I have an application in which i have a custom splash view controller and then the tab bar controller comes. Currently i have set the tab bar controller as the initial view controller . But i want the splash view controller appears first and then the tab bar controller . Any idea how to do this?

like image 281
Amelia frensheo Avatar asked Dec 25 '22 05:12

Amelia frensheo


2 Answers

Instead of 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.present(navigationController, animated: true, completion: nil)
}
like image 126
Sijil S Avatar answered Dec 26 '22 17:12

Sijil S


First of all in storyboard make custom class view controller as Initial view controller. And after that push tabbar controller to current navigation controller.

let tabBar = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBar, animated: true)
like image 30
Lijith Vipin Avatar answered Dec 26 '22 17:12

Lijith Vipin