Disabling bar button item (on the right) in a navigation bar


I am trying to disable the navigation bar button item (ie. the Edit button on the right of the navigation bar). I’m able to do this by setting self.navigationItem.rightBarButtonItem?.isEnabled = false. However, if I segue to a new view controller and then come back to the original window, the bar button becomes enabled even though it was disabled when I segued to the other screen.

I tried setting the right bar button item to disabled in viewWillAppear() but it still doesn’t work.

Does anyone know why this doesn’t work when you segue back?


Can anyone help with this?

How are you coming back to the original window?
Is it another segue, or just using the back button in the navigation bar?