title: Dismiss pushed view controller
body: <p>So I have a view controller which I display as follows:</p>
  
  <pre><code>func showProfileForTrainer(trainer: Trainers) {
      let viewPTProfileVC = ViewPTProfileVC()
      viewPTProfileVC.trainer = trainer
      self.navigationController?.pushViewController(viewPTProfileVC, animated: true)
  }
  </code></pre>
  
  <p>But when trying to dismiss the view, I cannot get it to work. It has a back button in a navigation bar which functions fine, but when trying to dismiss the view via a button for example, it does nothing. I have currently tried:</p>
  
  <pre><code>func handleMessageTrainer() {
      dismiss(animated: true) {
          print(1)
          self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
      }
      self.dismiss(animated: true) {
          print(2)
          self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
      }
      navigationController?.dismiss(animated: true, completion: {
          print(3)
          self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
      })
      self.navigationController?.dismiss(animated: true, completion: {
          print(4)
          self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
      })
      print(5)
  }
  </code></pre>
  
  <p>As you can see I have tried varying ways and none work, and the console just outputs <code>5</code>. </p>
  
  <p>Frustratingly, elsewhere in my app I presented a view in the same way as shown at the beginning and it dismissed fine using <code>dismiss(animated: true) { ... }</code></p>
  
  <p>Any idea why it won't work here?</p>