0

There's a good chance I missed something major here but I'll ask anyway. In my storyboard app I've sub classed UINavigationController to my needs. (using a simple .h & .m files) I've added a custom back button, a menu button and some other stuff that will be visible in the Navigation bar across my app.

My question is, how can I add objects (UIView , UIButton etc') to my sub classed UINavigationController using the interface builder? ( So far I've added everything I wanted through code)

Obviously I can't drag views to the UINavigationController. Is there a way to do it?

1 Answer 1

1

UPDATE

It is not possible to add subviews to a UINavigationController's view in Interface Builder. If you want to do that, you must do it in code.

ORIGINAL

You don't add subviews to the UINavigationController's view. You create a separate view controller and connect the navigation controller to the new view controller using the “root view controller” relationship segue. Then you add your views (buttons, etc.) to the root view controller's view. Here's an example:

storyboard with navigation controller and root view controller (Click for full size.)

The left view controller is the navigation controller. The right navigation controller is the root view controller. They are connected by the “root view controller” relationship (segue).

You cannot add buttons or any other views to the left view controller's scene. You can only add them to the right view controller's scene.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the reply. I think I was totally misunderstood. I've edited my question.. I've already added views to the Navigation Controller Subclass with code ( a custom back button, a menu that will always be visible on all views of the app etc') I was wondering if I can do the same with the interface builder instead of writing the code in my Navigation Controller subclass .m file
Ah. Well, the answer is no. Interface Builder will not let you add subviews directly to a navigation controller's view.
Please edit your answer and add the comment above so I can accept. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.