Skip to main content
kheftel
Inspiring
April 21, 2015
Question

Want to use pushViewController and segues from UINavigationController in AIR app on iOS

  • April 21, 2015
  • 0 replies
  • 1254 views

Ok, this might be a long shot, but here goes.

My iOS AIR app includes a bunch of native screens defined in a storyboard.  I have them included by putting them into a native (static) framework, including that framework in an ANE, and adding code to instantiate and add the various ViewControllers to the screen.

I can add a ViewController as a child and get its view to show on the screen with the following obj-c code in my ANE:

[[[[UIApplication sharedApplication] keyWindow] rootViewController] addChildViewController:controller];

        [[[[UIApplication sharedApplication] keyWindow] rootViewController].view addSubview:controller.view];

        [controller didMoveToParentViewController:[[[UIApplication sharedApplication] keyWindow] rootViewController]];

However, some of the views have child views that use segues and the push stack from UINavigationController.  When these screens try to load, I get the following error:

Apr 21 13:50:43 raspberry LKW_Smash[7703] <Error>: *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'MemberOptionsSegue'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

So I attempted to get access to the app's UIViewController, and push the new ViewController onto the stack with the following code:

[root.navigationController pushViewController:controller animated:YES];

But root.navigationController is nil!  It looks like the app doesn't have one!

So after all that, my question is this: How do I create an AIR app that includes a UINavigationController and is not simply just a single-view app?

This topic has been closed for replies.