Segev
Segev

Reputation: 19303

adding views to UINavigationController using the interface builder

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?

Upvotes: 0

Views: 1821

Answers (1)

rob mayoff
rob mayoff

Reputation: 385920

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.

Upvotes: 1

Related Questions