title: xcode navigation bar button state
body: <p>I have an edit button - UIBarButtonItem </p>
  
  <p><a href="https://i.stack.imgur.com/6kwGo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6kwGo.png" alt="enter image description here"></a></p>
  
  <p>which disappears from screen when it was clicked</p>
  
  <p><a href="https://i.stack.imgur.com/Bioeq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bioeq.png" alt="enter image description here"></a></p>
  
  <p>and appears when cancel button was clicked</p>
  
  <p><a href="https://i.stack.imgur.com/ooQJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooQJu.png" alt="enter image description here"></a></p>
  
  <p>As you can see, the state of edit button stays selected after appearing.
  How can I programmatically change Navigation bar buttons state to normal state? Or suggest me a better way.</p>
  
  <p>here is my project code</p>
  
  <pre><code>class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, introductionDelegate {
  
  var navBarEditButton: UIBarButtonItem?
  var navBarDeleteButton: UIBarButtonItem?
  var navBarCancelButton: UIBarButtonItem?
  
  override func viewDidLoad() {
      super.viewDidLoad()
      self.navBarEditButton = UIBarButtonItem(title: "Edit", style: .plain, target: self, action: #selector(editObjectsAction))
      self.navBarDeleteButton = UIBarButtonItem(title: "Delete", style: .plain, target: self, action: #selector(deleteObjectsAction))
      self.navBarCancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(cancelAction))
  
      self.navigationItem.leftBarButtonItems = [navBarEditButton!]
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  @objc private func editObjectsAction(_ sender: UIBarButtonItem) {
      self.navigationItem.leftBarButtonItems = [navBarCancelButton!, navBarDeleteButton!]
  }
  
  @objc private func cancelAction(_ sender: UIBarButtonItem) {
      self.navigationItem.leftBarButtonItems = [navBarEditButton!]
  }
  
  @objc private func deleteObjectsAction(_ sender: UIBarButtonItem) {
  
  }
  </code></pre>