For the following viewController hierarchy, isUserInteractionEnabled doesn't appear to be working as expected.
NavigationController(ViewController A) --- pushes to ---> NavigationController(ViewController B)
In ViewController A's viewDidAppear method I set navigationController?.navigationBar.isUserInteractionEnabled to false and set it to true in ViewController B's viewDidAppear method. However, upon popping ViewController B and returning to ViewController A, the navigation bar remains enabled for user interaction. Any thoughts as why this may be happening are greatly appreciated, thanks in advance!
That seems to be a bug for which you could get around by doing that on the main thread:
But this still leaves a millisecond window where the
navigationBar's interaction is enabled.You have to be really quick.
However...
I wouldn't recommend what you're doing; i.e. disabling the
navigationBar.You could lose the
backability, if it had one, because you're just disabling thenavigationBarentirely.Suggestion:
Since every
viewControllerin the navigation stack has it's ownnavigationItem, that contains it's own set ofbarButtonItems, I would recommend you keep references of theUIBarButtonItemand enable/disable them explicitly.i.e.
Furthermore, the state of this
barButtonItemis handled in thisviewControlleritself and you need not do things likeself.navigationController?.navigationBar.isUserInteractionEnabled = trueelsewhere.