Q:

Pushing a controller from a subview

In essence what is the correct way of pushing a new view controller from a sub view of a navigation controller.
The issue being subviews of the navigation view don't inherit the self.navigationController (its nil)
The reason is I need separate controllers for the navigation bar view & the main view but both need to push new controllers.
I am willing to change this model if someone can tell me the correct way of doing this.
Also:
AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate
[del.navigationController pushViewController:vc animated:YES];

Does not work as the delegates controller is nil.

A:

Create a following category on UIView.
@interface UIView (GetUIViewController)
- (UIViewController *)viewController;
@end

@implementation UIView (GetUIViewController)

- (UIViewController *)viewController;
{
    id nextResponder = [self nextResponder];
    if ([nextResponder isKindOfClass:[UIViewController class]]) {
        return nextResponder;
    } else {
        return nil;
    }
}
@end

Now get the SuperView from the subView.
mySuperView = [mySubView superview];

Then call the method from category created.
mySuperViewController = [mySuperView viewController];

Now, using this viewController, you can access the navigationController.
I have not tried the above code and approach, but I hope it should work.

