在PopOverView上添加MonoTouch对话框
本文关键字:MonoTouch 对话框 添加 PopOverView | 更新日期: 2023-09-27 18:24:02
我正试图将对话框添加到CustomPopoverViewController
(见图),但无法将其添加到视图中。我尝试过不同的方法,但不会显示。
[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")
}
}
}
};
}
}
我自己找到了答案。解决方案如下:
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);
}