简体   繁体   中英

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?

在此处输入图片说明

@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"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM