Programmatically navigate to another view controller/scene

后端 未结 19 3192
一向
一向 2020-11-27 11:29

I got an error message during navigating from first view controller to second view controller. My coding is like this one

let vc = LoginViewController(nibNam         


        
19条回答
  •  执念已碎
    2020-11-27 12:11

    I already found the answer

    Swift 4

    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
    let nextViewController = storyBoard.instantiateViewController(withIdentifier: "nextView") as! NextViewController
    self.present(nextViewController, animated:true, completion:nil)
    

    Swift 3

    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
    
    let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("nextView") as NextViewController
    self.presentViewController(nextViewController, animated:true, completion:nil)
    

提交回复
热议问题