简体   繁体   中英

Xamarin.iOS instantiate Storyboard Navigation controller in AppDelegate

I might be approaching this the wrong way, but I am trying to instantiate the NavigationController that I created in my storyboard into the AppDelegates FinishedLaunching method.

So, something like this:

 public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        initialViewController = Storyboard.InstantiateInitialViewController () as UIViewController;

        window.RootViewController = initialViewController;
        window.MakeKeyAndVisible ();
        return true;
    }

but instead of a ViewController, I want to be instantiating the NavigationController.

Can this be done?

Just set your navigation controller as the root controller in the storyboard. This is that little arrow (segue) pointing to the first controller.

You can then cast it with as UINavigationViewController if you need to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM