Push to iOS NavigationController from inside Modal View

I am new to iOS programming as well as to Stack Overflow. I tried to find the answer to my question, but the search did not return any results.

I am trying to disable the application stream, but I am having problems. I would like this to happen:

Initial view (NavigationController) → Search in the view (modal) → programmatically click different views on the initial view of the NavigationController from search mode before rejecting the view.

My understanding is that inside the modal representation I would have to do something like

[self.parentViewController.nagivationController pushViewController: someView] 

but it does not work at all. After rejecting the modal view, I just returned to the original view.

I also tried passing the link to the initial view navigation controller, but I can't do it right.

So, if anyone knows how to programmatically push views onto the navigation stack from within a modal view, I would love to know! I am really starting to think that my understanding of modal views is fundamentally wrong.

Thanks in advance for any help you can provide, as well as your patience with a complete newbie.

+4
source share
2 answers

Annnnd, 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" is completely unnecessary.

The correct link is:

 [self.parentViewController pushViewController: someView] 

Thanks for the comment, Rob.

+1
source

parentViewController returned null, but using presentingViewController worked. Swift 2.x:

  let vc = storyboard!.instantiateViewControllerWithIdentifier(CustomViewControllerID) as! CustomViewController if let navController = presentingViewController as? UINavigationController { navController.pushViewController(vc, animated: false) } 
0
source

Source: https://habr.com/ru/post/1379330/


All Articles