title: UINavigationController acting funny after pushViewController UPDATE 2
body: <p>I'm having a weird problem, I have a slide menu in my app, for some unknown reason every time that I go from one view to another using the .pushViewController instruction the navigation controller acts funny and it resets my UIBarButtonItems. (They change to their original tintcolor, and the badgeValue disappears).</p>
  
  <p>This is the methods I'm using in the slide menu to do the transition:</p>
  
  <pre><code>func openViewControllerBasedOnIdentifier(_ strIdentifier:String){
      let destViewController : UIViewController = self.storyboard!.instantiateViewController(withIdentifier: strIdentifier)
  
  
      let topViewController : UIViewController = self.navigationController!.topViewController!
  
      if (topViewController.restorationIdentifier! == destViewController.restorationIdentifier!){
          print("Same VC")
      } else {
          var numeroProductos = String(Carrito.numProd)
  
          self.navigationController!.pushViewController(destViewController, animated: true)
  
  
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>func slideMenuItemSelectedAtIndex(_ index: Int32) {
      let topViewController: UIViewController = self.navigationController!.topViewController!
      print("View Controller is : \(topViewController) \n", terminator: "")
      switch(index) {
      case 0:
          print("Home\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("Home")
  
          break
  
      case 1:
          print("Play\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("MiCuenta")
  
          break
  
      case 2:
          print("Play\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("QuienesSomos")
  
          break
  
      case 3:
          print("Play\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("NuestraCausa")
  
          break
  
      case 4:
          print("Play\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("Contacto")
  
          break
  
      case 5:
          print("Play\n", terminator: "")
  
          self.openViewControllerBasedOnIdentifier("FAQ")
  
          break
  
      default:
          print("default\n", terminator: "")
      }
  }
  </code></pre>
  
  <p>According to <a href="https://developer.apple.com/reference/uikit/uinavigationitem" rel="nofollow noreferrer">Apple's own documentation</a>: </p>
  
  <blockquote>
    <p>A UINavigationItem object manages the buttons and views to be
    displayed in a UINavigationBar object. When building a navigation
    interface, each view controller pushed onto the navigation stack must
    have a UINavigationItem object that contains the buttons and views it
    wants displayed in the navigation bar. The managing
    UINavigationController object uses the navigation items of the topmost
    two view controllers to populate the navigation bar with content.</p>
  </blockquote>
  
  <p>But this is clearly not happening, the button is there in the interfase builder and it works when I land on that view without using the slide menu, but it disappears when I click any option of my slide menu.</p>
  
  <p><a href="https://i.stack.imgur.com/CZLys.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CZLys.png" alt="enter image description here"></a></p>
  
  <p>This is the code I have on my viewDidLoad method on that view</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      addSlideMenuButton()
      Carrito.numProd = productosCarrito.count
      print(productosCarrito.count)
      var numeroProductos = String(Carrito.numProd)
      navigationItem.rightBarButtonItem?.badgeValue = numeroProductos
  
  }
  </code></pre>
  
  <p>If I reach the page without using the slidemenu (Like when you segue there after succesfully clearing the login view) the badgeValue is shown properly</p>
  
  <p><a href="https://i.stack.imgur.com/4Vqaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Vqaa.png" alt="enter image description here"></a></p>
  
  <p>But if I use the slide menu this happens</p>
  
  <p><a href="https://i.stack.imgur.com/GzZ5x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GzZ5x.png" alt="enter image description here"></a></p>
  
  <p>Any ideas on what could be causing this issue?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I discovered something.</p>
  
  <p>If I insert this instruction either in the openVIewControllerBasedOnIdentifier method or in the slideMenuSelectedAtIndex</p>
  
  <pre><code>navigationItem.rightBarButtonItem?.badgeValue = "25"
  </code></pre>
  
  <p>The badgevalue gets changed to that number just before disappearing, I'm also using this instruction</p>
  
  <pre><code>print("Badge Value:\(navigationItem.rightBarButtonItem?.badgeValue as Any)")
  </code></pre>
  
  <p>so the value is there because I get this in the debug console: </p>
  
  <pre><code>Badge Value: Optional("40")
  </code></pre>
  
  <p>But for some unknown reason it disappears</p>
  
  <p><strong>UDATE 2</strong></p>
  
  <pre><code> self.navigationController!.pushViewController(destViewController, animated: false)
  </code></pre>
  
  <p>I Discovered that if I turn off animation the badgevalue doesn't disappear, but I need the animation to work too.</p>