Search code examples
iosxamarin.iosuisplitviewcontrollermonotouch.dialog

MonoTouch.Dialog with UISplitViewController


I'm creating universal app with MonoTouch. When running on iPad I use UISplitViewController and build multi level menu in master view (on the left side) with MonoTouch.Dialog.

Problem is, that when I touch first root element it opens new view which covers whole screen instead of being inside master split view.

Question is, how can I make so next root element opens inside same view as it's parent?

All the examples I could find usually has one level menu on the master view so when you touch it displays something on the detail view.

Hope this makes sense.


Solution

  • Let's say you have an UISplitViewController and your CustomViewController.

    UISplitViewController split = ...;
    CustomViewController controller = ...;
    

    If you want to push the new controller on top of the current (master) one then use:

    var root = new RootElement ();
    var dvc = new DialogViewController (UITableViewStyle.Plain, root, true);
    dvc.ActivateController (controller);
    

    If you want to show the new controller in the details (right) section then use something like:

    UISplitViewController split = ...;
    var about = new StringElement ("About");
    about.Tapped += delegate {
        split.ViewControllers = new UIViewController [] {
            split.ViewControllers [0],
            controller
        };
    };