The UINavigationBar subclass detects that a change to the name of a navigation item

I use my own subclass of UINavigationBar with my UINavigationController using: initWithNavigationBarClass:toolbarClass:

Needless to say, in this subclass I need to track and update an additional interface element contained in my subclass of the navigation bar when the name of the presented navigation element changes. I considered using KVO to do this and observing the properties of the title navigation elements and updating when that changes, but I was wondering if it is possible that there is a better way. Can subclassing the UINavigationController give me even more control over this function? I am interested in hearing your thoughts on this and is there a better way to do this?


To develop: I transcend some methods, for example layoutSubviews . In this method, when the navigation item has just been pushed onto the stack, it does not yet have a name. This is due to the fact that the title is set in the viewDidLoad view viewDidLoad , which will not be executed until the view, which has not yet been loaded, is loaded. Thus, even though the navigation item has been clicked, the title is still nil until it is changed in the viewDidLoad view controllers. This is what I want to be notified about when the navigation item was changed after it was moved to the navigation stack.

+4
source share

Source: https://habr.com/ru/post/1494834/


All Articles