简体   繁体   English

Xamarin.iOS在AppDelegate中实例化Storyboard Navigation控制器

[英]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. 我可能会以错误的方式进行处理,但是我试图将我在情节提要中创建的NavigationController实例化为AppDelegates FinishedLaunching方法。

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. 但是我想实例化NavigationController,而不是ViewController。

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. 这是指向第一个控制器的那个小箭头(segue)。

You can then cast it with as UINavigationViewController if you need to. 然后as UINavigationViewController如果需要,可以使用as UINavigationViewController对其进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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