Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to iOS NavigationController from inside Modal View

I'm new to iOS programming and also to Stack Overflow. I've been trying to find an answer to my question, but searching hasn't yielded any results.

I'm trying to get the flow of my application down, but I'm running into issues. What I would like to have happen is this:

Initial view (NavigationController) -> Searching view (modal) -> programatically push different views onto the initial view's NavigationController from withing the searching view before dismissing the view.

My understanding is that inside the modal view, I should be able to do something like

[self.parentViewController.nagivationController pushViewController: someView]

but that doesn't work at all. After dismissing the modal view I'm just back at the initial view.

I've also attempted to pass a reference to the initial view navigation controller, but I can't seem to make that work right.

So if anyone knows how to programatically push views onto a navigation stack from inside a modal view, I'd love to learn! I'm really starting to think that my understanding of modal views is fundamentally flawed.

Thanks in advance for any help you can provide, and also your patience with a complete newb.

like image 290
Will Voorhees Avatar asked Nov 14 '22 15:11

Will Voorhees


1 Answers

Annnnnd, I'm dumb.

I had the right approach, but it took me a day to realize that self.parentViewController returns a UINavigationController, so the extra ".navigationController" was completely unnecessary.

Correct reference:

[self.parentViewController pushViewController: someView]

Thanks for commenting, Rob.

like image 90
Will Voorhees Avatar answered Jun 08 '23 20:06

Will Voorhees