在PopOverView上添加MonoTouch.Dialog

时间:2012-02-08 22:36:28

标签: c# xamarin.ios monotouch.dialog

我正在尝试向CustomPopoverViewControllersee picture)添加对话框,但我无法将其添加到视图中。我尝试过不同的方法,但不会显示。

[Register("MyCustomPopoverViewController")]
public partial class MyCustomPopoverViewController : UIViewController
{
    DetailViewController appd;

    public MyCustomPopoverViewController (DetailViewController app)
    {
        appd = app;
    }

    public override void ViewDidLoad ()
    {
        Console.WriteLine ("Paged view did load");
        this.ContentSizeForViewInPopover = new SizeF (370, 670);

        var root = new RootElement ("Meals"){
        new Section ("Dinner"){
                new RootElement ("Desert", new RadioGroup ("desert", 2)){
                    new Section (){
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert")
                    }
                }
            }       
        };
    }   
}

1 个答案:

答案 0 :(得分:3)

我找到了自己的答案。解决方案是这样的:

        public override void ViewDidLoad ()
    {
        Console.WriteLine ("Paged view did load");
        this.ContentSizeForViewInPopover = new SizeF (370, 670);

        var root = new RootElement ("Meals"){
        new Section ("Dinner"){
                new RootElement ("Desert", new RadioGroup ("desert", 2)){
                    new Section (){
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert"),
                    new RadioElement ("Ice Cream", "desert")
                    }
                }
            }       
        };
                    // This is the solution!
        var dv = new DialogViewController (root);
        View.Add(dv.View);
    }