UINavigationBarDelegate
Methods that a navigation bar calls before and after it modifies its stack of navigation items.
Declaration
@MainActor protocol UINavigationBarDelegate : UIBarPositioningDelegateOverview
The UINavigationBarDelegate protocol defines optional methods that a UINavigationBar delegate implements to update its views when items push or pop from the stack. The navigation bar represents only the bar at the top of the screen, not the view below. It’s the application’s responsibility to implement the behavior when the top item changes.
You can control whether a navigation bar pushes an item on or pops an item from the stack by implementing the navigationBar(_:shouldPush:) and navigationBar(_:shouldPop:) methods. These methods return true if the action is allowed; otherwise, false.
The screen always reflects the top item on the navigation bar. You implement the navigationBar(_:didPush:) method to update the view below the navigation bar to reflect the new item. Similarly, you implement the navigationBar(_:didPop:) method to replace the view below the navigation bar.