Samah Ahmed
Samah Ahmed

Reputation: 419

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

Upvotes: 0

Views: 780

Answers (2)

Chandan
Chandan

Reputation: 757

@SamahAhmed

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

//create a variable for e.g : data at MyTabbarController and set like

diallerTBC.data = "testing"

Upvotes: 0

Chandan
Chandan

Reputation: 757

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

Upvotes: -1

Related Questions