How to open a partial view from controller as a Jquery Mobile dialog?

Dynamically duplicate a view controller to be pushed to navigation controller?

  • I currently have an iOS6 project where my Ma∈.s→ryboardMa∈.s→ryboardMain.storyboard file consists of a main navigation controller as initial view controller which presents a collection view controller as first view controller to be displayed. That collection view controller lists products categories and when tapping on a category, it jumps to the category definition view. What also happens is that in some cases the category has sub-categories and when tapping that category another identical view should be pushed to the navigation view controller to display the sub-categories, basically it is the exact same view as the previous categories view but with changed datasource. Here it is an example for better understanding: My question here is, do I need to manually duplicate the same category collection view controller on Interface Builder and reference to it? Couldn't I have just one Category Collection view controller and push a duplicate to the main navigation controller when needed? If so, how it is possible to achieve that? I would need that new view to be pushed to navigation controller so I can still go back to the main category view through the nav bar. I hope this all makes, sense. thank you in advance

  • Answer:

    The way to do it while making the best use storyboards is to create one that looks just like your mockup - a second instance of the collection view controller. But that sucks, because anytime you need to change one in the future you've got to remember to change the other. What would be best is some kind of "loop segue", where a segue has the same View Controller as it's source and destination, but I don't think that is possible. So I think this should work (never tried it before, but don't see why there might be a problem with this approach) - just have one instance of your collection view controller in the storyboard, and give it an identifier. Wire up a method to get called when the user taps a category. In that method, if the user tapped a category with subcategories, use the Storyboard's instantiateViewControllerWithIdentifier: method to create another instance of the View Controller you gave an identifier to. Then, manually push that view controller onto the navigation stack.

Brian Papa at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.