Programmatically navigate to another view controller/scene

后端 未结 19 3280
一向
一向 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:16

    Programmatically there are different ways based on different situations

    1. load storyenter code hereboard nib file

      let yourVc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "YourViewController") as! YourViewController;
      self.present(yourVc, animated: true, completion: nil)
      
    2. Load from xib

      let yourVc = YourViewController.init(nibName: "YourViewController", bundle: nil)
      self.present(yourVc, animated: true, completion: nil)
      
    3. Navigate through Segue

      self.performSegue(withIdentifier: "your UIView", sender: self)
      

提交回复
热议问题