Search code examples
iosswiftxcodeuiviewcontrollerstoryboard

Is this possible to Set ViewController Storyboard ID programmatically?


please check this ss

In ss we can set Storyboard id using Interface Builder but I don't want to use this so is this possible programmatically? if yes, then please give me any solutions.


Solution

  • When you programmtically create a VC , then you don't have to load it with identifier you only need

    let first = FirstVC()
    

    // in AppDelegate didFinishLaunchingWithOptions it's suppose you use

    self.window?.rootViewController = UINavigationController(rootViewController: first) 
    

    then inside the first

    let second = SecondVC()
    self.navigationcontroller?.pushViewController(second,animated:true)