I have a UINavigationBar subclass, is it possible someway from that UINavigationBar to get my UINavigationController?
I have a UINavigationBar subclass, is it possible someway from that UINavigationBar to get
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not a good design pattern. You should put the navigation logic into your view controllers. If you have controls (such as buttons) in your custom navigation bar, you should also handle these events in your view controllers.
Note that the
UINavigationBardoes not deal with the controllers (it should be the other way round), rather it deals with theUINavigationItems, which will look different according to if they are on top of the navigation stack or not.There is a trick to make your custom navigation bar the
navigationBarproperty of your view controller’s navigation controller. Normally this is a read-only property. But you can put it into your navigation controller in Interface Builder in Xcode, and then change the class name in the inspector to your custom class. You will then be able to refer to your bar with the usualself.navigationController.navigationBarfrom within your view controller.