Chandler De Angelis
Chandler De Angelis

Reputation: 2766

How to add UIView to UINavigationController stack

I have a UIView that I add as a subview to the UIViewControllers in my UINavigationController's stack, which is just a side menu, like in the Facebook iOS app. I need to add the UIView to the navigationController, so that I can push new viewControllers onto the stack. Does anyone know how I can do this?

Upvotes: 0

Views: 1121

Answers (1)

henTdev
henTdev

Reputation: 848

A navigation controller works like a stack so you can push and pop viewcontroller exactly like a stack behaves in the real world. Think of a navigation controller as a stack of viewcontrollers, so you cant actually add a uiview, but what you would like to do instead is to add the uiview as a subview in your view controller and push that view controller onto the navigation controller stack with a simple:

[navigationcontroller pushViewController:aViewcontroller];

I suggest you to read the docs so you can have a better grasp of how navigationcontrollers work: http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/

-its important to mention that at first you need to set your navigation controller root view controller - the first vc to appear.

navigationController.rootViewController = aViewController;

Upvotes: 1

Related Questions