Monotouch:如何将UIView添加到DialogViewController
在我的一个屏幕中,我需要将UIView(带有一些标签和按钮)添加到DialogViewController。原因是我没有使用TableView标题,因为我不想在滚动表格时滚动此视图 如果我将自定义视图添加到导航栏中,我可以实现这一点,但我的视图将不会收到任何触摸(导航控制器会吃掉它们) 我还尝试将自定义视图添加到DialogsViewController父控制器中,在工作时,在LoadView()中调整tableview框架的大小没有任何作用 是否有其他方法向DialogViewController添加自定义视图Monotouch:如何将UIView添加到DialogViewController,uiview,xamarin.ios,dialogviewcontroller,Uiview,Xamarin.ios,Dialogviewcontroller,在我的一个屏幕中,我需要将UIView(带有一些标签和按钮)添加到DialogViewController。原因是我没有使用TableView标题,因为我不想在滚动表格时滚动此视图 如果我将自定义视图添加到导航栏中,我可以实现这一点,但我的视图将不会收到任何触摸(导航控制器会吃掉它们) 我还尝试将自定义视图添加到DialogsViewController父控制器中,在工作时,在LoadView()中调整tableview框架的大小没有任何作用 是否有其他方法向DialogViewControll
谢谢。要添加不滚动的标题,您可以创建一个控制器,其视图既包含要添加的其他视图,也包含对话框ViewController的视图。例如,以下简单示例将UILabel与DialogViewController的视图一起添加为附加控制器(本例中称为容器)的子视图: 然后,DialogViewController在ViewDidLoad方法中调整TableView的高度:
public partial class MyDialogViewController : DialogViewController
{
float labelHeight;
public MyDialogViewController (float labelHeight) : base (UITableViewStyle.Grouped, null)
{
this.labelHeight = labelHeight;
Root = new RootElement ("MyDialogViewController") {
new Section (){
new StringElement ("one"),
new StringElement ("two"),
new StringElement ("three")
}
};
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
TableView.Frame = new RectangleF (TableView.Frame.Left, TableView.Frame.Top + labelHeight, TableView.Frame.Width, TableView.Frame.Height - labelHeight);
}
}
以下是显示模拟器中结果的屏幕截图:
public partial class MyDialogViewController : DialogViewController
{
float labelHeight;
public MyDialogViewController (float labelHeight) : base (UITableViewStyle.Grouped, null)
{
this.labelHeight = labelHeight;
Root = new RootElement ("MyDialogViewController") {
new Section (){
new StringElement ("one"),
new StringElement ("two"),
new StringElement ("three")
}
};
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
TableView.Frame = new RectangleF (TableView.Frame.Left, TableView.Frame.Top + labelHeight, TableView.Frame.Width, TableView.Frame.Height - labelHeight);
}
}