Have a dedicated UIViewController for each RootElement in MonoTouch.Dialog?

后端 未结 2 616
余生分开走
余生分开走 2021-01-19 15:28

It\'s easy to create a multi-level menu structure using nested RootElements in MonoTouch.Dialog but how would you go about having a specific

相关标签:
2条回答
  • 2021-01-19 15:56

    Same thing, less methods...

        var root_element = new RootElement("caption", (RootElement e) => {
            return new DialogViewController (e);
        });
    
    0 讨论(0)
  • 2021-01-19 16:13

    I think you're looking for this:

    public RootElement (string caption, Func<RootElement, UIViewController> createOnSelected)
    

    which let you create the UIViewController (e.g. a DialogViewController that you customized or a type that inherit from it).

    This will let you keep nesting your Element while giving most of the control over the view and it's controller.

    UPDATE

    Here's how this can be used:

    First declare your method that will create the UIViewController. The method signature must match Func<RootElement, UIViewController>, e.g.

        static UIViewController CreateFromRoot (RootElement element)
        {
            return new DialogViewController (element);
        }
    

    Next create your root elements using:

        var root_element = new RootElement ("caption", CreateFromRoot);
    

    The above will give you the same as:

        var root_element = new RootElement ("caption");
    

    except you're now able to customize the DialogViewController to your liking before returning it.

    0 讨论(0)
提交回复
热议问题