I have a UIViewController “NavigationViewController” that is added as a subview of my “FirstViewController” that takes up the whole screen (i.e. similar to the Flipboard Navigation controller in the iPad application). Many views are added and removed based on what selection the user makes. I want to be able to push a view controller to the “FirstViewController” navigationController from within the “many views” that are added. In this case the “FeaturedViewController” is one of those many views that can be selected. It inherits ContentViewController where the delegate protocol is defined.
TL;DR I want to access the navigationcontroller in the first view to push a view from the added subview “FeaturedViewController”.
Here is a visual representation:

Here is the my code from:
Here is my current attempt that does not work. Note, I took some code out relating to the “Navigation Controller”
/* First View Controller */
#import <UIKit/UIKit.h>
#import "ContentViewController.h"
@interface ViewController : UIViewController <BaseViewDelegate, ContentViewDelegate>
{
IBOutlet UINavigationController *navigationController;
ContentViewController *contentView;
}
@property (strong, nonatomic) IBOutlet UINavigationController *navigationController;
@property (strong, nonatomic) ContentViewController *contentView;
---------------------------------------------------------
#import "ViewController.h"
#import "NavigatorViewController.h"
#import "BinViewController.h"
@implementation ViewController
@synthesize navigationController, contentView;
static NSArray *viewArray = nil;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:navigationController.view];
// Navigation View is used to navigate throughout the entire application
NavigatorViewController *navController = [[NavigatorViewController alloc] init];
contentView = [[ContentViewController alloc] init];
contentView.delegate = self;
// Add the views to the array (using ARC)
viewArray = [NSArray arrayWithObjects:navController, contentView, nil];
}
-(void)displayNavigator
{
// Get the right view controller
UIViewController *viewController = [viewArray objectAtIndex:0];
// Add the subview to the view
[self.view addSubview:viewController.view];
}
-(void)pushViewController:(UIViewController *)viewController
{
NSLog(@"First View Push View Controller called");
[self.navigationController pushViewController:viewController animated:YES];
}
@end
/* Content View Controller */
@class ContentViewController;
@protocol ContentViewDelegate <NSObject>
-(void)pushViewController:(UIViewController *)viewController;
@end
@interface ContentViewController : UIViewController
{
__weak id <ContentViewDelegate> delegate;
}
@property (weak) __weak id <ContentViewDelegate> delegate;
- (void)pushView:(UIViewController *)viewController;
@end
---------------------------------------------------------
#import "ContentViewController.h"
#import "BinViewController.h"
@implementation ContentViewController
@synthesize delegate;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)pushView:(UIViewController *)viewController
{
NSLOG(@"Push View from ContentViewController");
if ([delegate respondsToSelector:@selector(pushViewController)])
[delegate pushViewController];
}
@end
/* View that is added to the navigator view (it inherits ContentViewController where the delegate protocol is defined)*/
#import <UIKit/UIKit.h>
#import "ContentViewController.h"
@interface FeaturedViewController : ContentViewController <CustomPagingDelegate>
@end
---------------------------------------------------------
#import "FeaturedViewController.h"
#import "BinViewController.h"
@implementation FeaturedViewController
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void) touchUpInsideItemAtIndex:(NSUInteger)itemIndex
{
// [[[[[self view] superview] superview] superview] removeFromSuperview];
NSLOG(@"Touch up inside from featured view");
BinViewController *binViewController = [[BinViewController alloc] init];
[self pushView:binViewController];
}
@end
Many to one or one to many sounds like easiest route would be to use NSNotificationCenter.