Samah Ahmed Samah Ahmed - 4 months ago 21
iOS Question

Initial view controller and Tab View Controller

I'm working with a single view app but also I'm using Tab View controller at one case , but the Tab view Controller must be put as initial view controller to work so how I can use Tab view controller without make it as initial view Controller?

enter image description here

Answer

When you are clicking on button to move tabbar controller

Provide a storyboard id to tabbar and use below code

Write this as a class method in appdelegate and call it on button click

        let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
        let diallerTBC = storyboard.instantiateViewControllerWithIdentifier("tabBarStoryboardId") as! UITabBarController

        self.window?.rootViewController = diallerTBC
        self.window?.makeKeyAndVisible()
    }

I hope this will work

Thanks

Comments