Amelia frensheo Amelia frensheo - 6 months ago 16
iOS Question

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?

Answer
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.presentViewController(navigationController, animated: true, completion: nil)

        }
Comments