title: How to switch to other view controller programmatically in Swift 4?
body: <p>I need to switch page(other view controller) using a button.
  I have two controllers (viewController to HomeViewController) 
  I have a button created in viewController:</p>
  
  <pre><code>let acceptButton: UIButton = {
      let button = UIButton(type: .system)
      button.setTitle("Accept", for: .normal)
      button.setTitleColor(.blue, for: .normal)
      button.translatesAutoresizingMaskIntoConstraints = false
      button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
      button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
      //button.sendAction(Selector(buttonAction), to: HomeViewController(), for: .touchUpInside)
  
      return button
  
  }()
  </code></pre>
  
  <p>and I have set a function and used a print statement to test the function:</p>
  
  <pre><code> @objc func buttonAction(sender: UIButton){
   print("button pressed")
  }
  </code></pre>
  
  <p>I executed the program and when I press the button it prints out "button pressed" </p>
  
  <p>Then I added the following into the function:</p>
  
  <pre><code>  let HomeViewController = ViewController(nibName: ViewController, bundle: nil)
    self.presentViewController(HomeViewController, animated: true, completion: nil)
  </code></pre>
  
  <p>As a result, it does not switch to other viewController(HomeViewController).</p>
  
  <p>Any idea on how should I make it works? Thank you</p>