[Solved] How to set up UINavigationController

I've seen that I can call Component::getWindowHandle to get at the underlying UIView pointer for a JUCE component. 

How would I be able to get at the JuceUIViewController pointer? 

I want to be able to use a UINavigationController and add a UINavigationBar to the top of my app. 

 

UPDATE: Working example project up at https://github.com/adamski/juce-ios-navigation

OK, so I'm trying to do something like this but not quite sure how to get there:

In my MainWindow constructor - 

UIView* view = getTopLevelComponent()->getWindowHandle();

UIViewController* viewController = view.rootViewController;

This complains that UIView and UIViewController arent recognised type names. I tried JuceUIView but that is not recognised either. 

Does this need to be in a seperate Objective-C section of my file? I've renamed Main.cpp to Main.mm

Any tips much appreciated

OK I found an example: http://www.juce.com/forum/topic/access-juceuiviewcontroller

I'm working on an example demo app, so far I have the default JUCE GUI app running with the UINavigationController and UINavigationBar. You can see it at https://github.com/adamski/juce-ios-navigation

It needs some tidying up and to get the back button appearing but I'm happy that I got the basic mechanism working.

 

 

 

 

 

I mocked up a demo like this a short time ago and found it easiest to bypass the juce TopLevelWindow and just create my own UIWindow at launch. Once you've done that you can add a UINavigationController to push/pop UIViews as you like.

Once you have a UIView it's trivial to add a juce component to it using addToDesktop with the UIView as the nativeWindowToAttachTo.

Ah OK thanks, I might try that approach too. I'm currently using getTopLevelComponent()->getWindowHandle() to get the view, then nextResponder on the UIView to get the controller, then nextResponder on the UIViewController to get the window...  feels a little faffy and brittle if the heirarchy changes.

Would you be up for sharing your demo code at all?

 

I've updated the demo with dave96's suggestions - much better, and now the back button works :)

EDIT: Made it more cross platform and styled the navigation bar

https://github.com/adamski/juce-ios-navigation