I already read multiple posts regarding this, but couldn't get it working.
Posts I already read:
I have a ViewController-A
embedded in a UINavigationController
. The navigation bar
of the controller contains a rightBarButtonItem
. Code for adding rightBarButtonItem
:
let searchButton = UIBarButtonItem(image: UIImage(named: "HomeSearch"), style: .plain, target: self, action: #selector(navigateToSearchScreen))
self.navigationItem.rightBarButtonItem = searchButton
When another ViewController-B
is pushed in the navigation stack and popped back, the rightBarButtonItem
disappears from the navigation bar.