Search code examples
xcodepushviewcontroller

Xcode can't change View Controller


let profileViewController = 
self.storyboard?.instantiateViewController(withIdentifier: 
"ProfileViewcontroller") as! ProfileViewController

self.navigationController?.pushViewController(profileViewController, 
animated: true)

http://prntscr.com/i87reg

Don't understand, why it isset working.


Solution

  • Can you try initializing storyboard ?

    Either storyboard or navigationController is nil.

     let storyboard = UIStoryboard(name: "Main", Bundle: Bundle.main) 
     let profileViewController = storyboard.instantiateViewController(withIdentifier: "ProfileViewcontroller") as! ProfileViewController
     self.navigationController?.pushViewController(profileViewController, animated: true)
    

    enter image description here enter image description here