FlyoutNavigation - iOS

Emi*_*sen 6 c# uiviewcontroller uinavigationcontroller ios xamarin

我正在尝试使用Clancey FlyoutNavigation,但是我无法让它执行一个segue.

我希望它像导航菜单一样工作,所以如果我按下"开始"它会转到我的故事板上的某个视图

这是我目前的代码,但它根本不起作用.

var navigation = new FlyoutNavigationController {
                // Create the navigation menu
                NavigationRoot = new RootElement ("Navigation") {
                    new Section ("Pages") {
                        new StringElement ("Start"),
                    }
                },
                // Supply view controllers corresponding to menu items:
                ViewControllers = new [] {
                    new UIViewController { this.PerformSegue("toError", this) },
                },
            };
            // Show the navigation view
            navigation.ToggleMenu ();
            View.AddSubview (navigation.View);
Run Code Online (Sandbox Code Playgroud)

Mag*_*ørn 2

我不知道您是否仍然需要解决这个问题的帮助,因为这个问题是去年提出的,但我所做的是创建一个继承“FlyoutNavigationController”的自定义菜单控制器。这样,添加我想要从任何视图导航到的菜单的新实例真的很容易。我编写自定义菜单的方式是这样的:

首先,我创建了我希望能够导航到的菜单的新实例:

UINavigationController planningViewController = new UINavigationController(new PlanningViewController());
Run Code Online (Sandbox Code Playgroud)

然后我将它们添加到数组中:

UIViewController[] viewcontrollers = new [] { planningViewController };
Run Code Online (Sandbox Code Playgroud)

然后我将它们添加到 RootElement 中:

NavigationRoot = new RootElement ("Planning") 
{ 
    new Section ("Menu") 
    {
        new StringElement ("Rooster"),
    },
};
Run Code Online (Sandbox Code Playgroud)

其余的编码是关于添加用于单击菜单元素的委托。我使用单独的 FlyOutDataSource 来处理程序应引导您进入哪个菜单,但这可以在与声明菜单的类相同的类中完成。您可以使用单击元素的索引来确定应导航到哪个菜单。