0

Okay guys, now that I have fixed this because of your help,

the error has gone.

but the page won't move to the 'requirementVC', so the button when i clicked, it just doesn't do anything.

@IBAction func buttonOK(_ sender: Any) {

    let button = (self.storyboard?.instantiateViewController(withIdentifier: "RequirementsVC") as! requirementVC)
    self.navigationController?.show(button, sender: nil)

}

Thankyou again, appriciate it!

Aldo Sugiarto
  • 197
  • 3
  • 20
  • your button's class is ViewController not a requirementVC, are you sure with identifiers? – Alexandr Kolesnik Nov 27 '19 at 09:24
  • check this https://stackoverflow.com/questions/24038215/how-to-navigate-from-one-view-controller-to-another-using-swift – Sailendra Nov 27 '19 at 09:27
  • Does this answer your question? [How to Navigate from one View Controller to another using Swift](https://stackoverflow.com/questions/24038215/how-to-navigate-from-one-view-controller-to-another-using-swift) – Sailendra Nov 27 '19 at 09:28
  • Have you set the storyboard controller class name requirementVC? – Faysal Ahmed Nov 27 '19 at 09:34

2 Answers2

0

You can do the following...

@IBAction func buttonOK(_ sender: Any) {

  let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "RequirementsVC") as! requirementsVC
  self.navigationController?.pushViewController(vc, animated: true)

}

Here Main is the name of the storyboard.

RequirementsVC should be storyboard id set in storyboard.

And requirementsVC should be the subclass of the UIViewController.

//Class name should always start with capital letter. So rename requirementsVC to "RequirementsVC"
class RequirementsVC: UIViewController {

    //class body

}
Mahendra
  • 8,448
  • 3
  • 33
  • 56
0

just set your identifier and class of viewController you want to go on in this code :=

    let addReminderVc = self.storyboard?.instantiateViewController(withIdentifier: "AddReminderVC") as! AddReminderVC
    self.navigationController?.pushViewController(addReminderVc, animated: true)
viral goti
  • 63
  • 10
  • i did everything u said, i've set the storyboard id, set it to asction, & so on, it run fine but the only thing when i click the button, nothing happened. nothing change. – Aldo Sugiarto Nov 28 '19 at 03:30
  • did you check for getting nil navigation controller by setting break point. so, may be you did not Embed your initial Vc in NavigationController. – viral goti Nov 28 '19 at 05:42