Search code examples
iosswiftuser-interfaceuinavigationcontrollerstoryboard

Storyboard returns nil on main controller after login


I am using a single Storyboard named as Main and when I am trying to redirect(push) from login screen to Home screen, On Home screen in ViewDidLoad I am getting self.storyboard is nil so UI is distorting(view, Buttons, labels are changing its position). I am getting this problem too frequent but not every-time.

Can anyone please help me out, it would be appreciated.


Solution

  • Try this

    let startViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "StartViewController") as? StartViewController
    self.navigationController?.pushViewController(startViewController!, animated: true)