Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FlyoutNavigation - iOS

I am trying to work with the Clancey FlyoutNavigation, however I can't get it to perform a segue.

I want it to work like a navigation menu, so if I press on "Start" it goes to a certain view on my storyboard

here is my current code, but it does not work at all.

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);
like image 769
Emil Elkjær Avatar asked Dec 04 '13 16:12

Emil Elkjær


1 Answers

I don't know if you still need help with this issue, seeing as this question was asked last year, but what I did was create a custom menu controller, that inherited the "FlyoutNavigationController". This way, it was really easy to add new instances of menus I wanted to navigate to from any view. The way I coded my custom menu was like this:

First I made new instances of the menus I wanted to be able to navigate to:

UINavigationController planningViewController = new UINavigationController(new PlanningViewController());

Then I added them to a array:

UIViewController[] viewcontrollers = new [] { planningViewController };

Then I added them to the RootElement:

NavigationRoot = new RootElement ("Planning") 
{ 
    new Section ("Menu") 
    {
        new StringElement ("Rooster"),
    },
};

The rest of the coding is about adding delegates for clicking on the menu-elements. I use a seperate FlyOutDataSource to handle to which menu the program should lead you, but this could be done in the same class as where you declare your menu. You could use the index of the clicked element to determine which menu you should navigate to.

like image 83
Magicbjørn Avatar answered Nov 11 '22 12:11

Magicbjørn