views:

594

answers:

1

I have a UINavigationViewController and inside that I have added a UITableViewController as a subview.

I'd like to be able to tell the UINavigationViewController pushViewController from inside the UITableViewController, but I am unable to retrieve the correct navigationController object.

I have tried some of the methods discussed in this thread, but I cannot get the navigationController for the view.

Is there a way to get a reference for the 'owning' view for a subview?

EDIT: I was able to do this:

[[(MyAppDelegate *)[[UIApplication sharedApplication] delegate] mainViewController].navigationController pushViewController:oOptionsViewController animated:YES];

To make it work. But the issue is just I'd like to do it without necessarily knowing the specific name of the navigationController (say it I have several of these instances, where I use the same class, but they may be used in other navigation controllers..)

+1  A: 

I think what you've done there is perfect.

navigationController is an instance-variable, so each controller instance will get its own, and they can be set to different things depending on what navigation element they're added to.

Later,
Blake.

bwinton

related questions