Xamarin.ios 如何在Monotouch.Dialog中设置popover大小?

Xamarin.ios 如何在Monotouch.Dialog中设置popover大小?,xamarin.ios,monotouch.dialog,Xamarin.ios,Monotouch.dialog,我有以下设置: 我的控制器继承了UINavigationController 它包含一个DialogViewController 我的控制器的ContentSizeForViewInPopover设置为400 | 400 对话框ViewController的ContentSizeForViewInPopover也设置为400 | 400 对话框视图控制器中的一个元素公开了一长串子元素。如果此列表比我定义的400个单元长,则如果将此列表推到导航控制器上,popover控制器的高度将增加。这很好

我有以下设置:

  • 我的控制器继承了UINavigationController
  • 它包含一个
    DialogViewController
  • 我的控制器的
    ContentSizeForViewInPopover
    设置为400 | 400
  • 对话框ViewController的
    ContentSizeForViewInPopover
    也设置为400 | 400
对话框视图控制器中的一个元素公开了一长串子元素。如果此列表比我定义的400个单元长,则如果将此列表推到导航控制器上,popover控制器的高度将增加。这很好,但是如果我返回上一个菜单,大小将不会调整为我定义的400个单位


有没有办法告诉DialogViewController不要更改大小?

您可以显示特定使用MonoTouch.Dialog的代码吗?您可能会看到这种行为,因为每次TopViewController更改时,UIPopoverController都会尝试自动协商它自己的ContentSize

您应该通过覆盖WillShowViewController方法并在那里设置SizeF,为每个呈现的UIViewController设置ContentSizeForvieWinPover

public class NavDelegate : UINavigationControllerDelegate 
{
    public NavDelegate()
        : base() 
    {
    }

    public override void WillShowViewController(UINavigationController navigationController, UIViewController viewController, bool animated)
    {
        base.WillShowViewController(navigationController, viewController, animated);

        viewController.ContentSizeForViewInPopover = new SizeF(.., ..);
    }
}