iPhone accessing navigation controller from a subview
I have a navigation controller that loads a tableview, from here the user can select a row which loads a detail view that gets pushed onto the stack. This detail view controller has a segmented control in the bottom bar which loads in a series of views using [self.view insertSubview:firstDetailViewController.view atIndex:0]; etc...
That works fine - one of the subviews loaded also contains a table which loads another detail view. This caused problems because I couldn't access the navigation controller from within the sub view. To do so I had to use:
YourAppDelegate *del = (YourAppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:nextViewController animated:YES];
Which I found here: Accessing a Top Navigation Controller from a Subview Navigation Controller.
But there's another instance where similar functionality is required. From the home view controller a lists view is loaded and presented modally. From here I push 2 detail views onto this new navigation stack using self.navigationController etc... which works fine. But when the subview tries to push the detail view it doesn't work. self.navigationController doesn't work, the appDelegate one pushes them onto the other nav controller and self.parentVi开发者_StackOverflow中文版ewController.navigationController doesnt work.
Any ideas?
So your Home VC does presentModalVC of a table view. The table view does a self.NavCon pushVC: detail. And the detail then fails to push a sub-detail. Is that the scenario?
I'm wondering where the tableview got it's nav controller from, since it was presented modally, which does not require a NavCon.
I'm also wondering if you could push the tableview onto the NavCon instead of presenting modally; then the detail should have an intact NavCon which could then in turn push a sub-detail.
Hope that helps. -Mike
精彩评论