2012-03-01 84 views
0

我有以下设置:如何在Monotouch.Dialog中设置弹出窗口大小?

  • 我控制器继承UINavigationController
  • 它拥有的DialogViewController成员
  • 我的控制器的ContentSizeForViewInPopover设置为400 | 400
  • 的DialogViewController的ContentSizeForViewInPopover也被设置为400 | 400

一个在对话框视图控制器公开的元件的一大串子元素。如果此列表长度超过我定义的400个单位,则如果此列表在导航控制器上按下,则弹出窗口控制器的高度将会增加。这很好,但是如果我回到上一个菜单,大小将不会调整到我定义的400个单位。

有没有办法告诉DialogViewController不改变尺寸?

回答

0

你可以显示你的特定用法的MonoTouch.Dialog的代码?您可能会看到此行为,因为每次TopViewController更改时... UIPopoverController将尝试自动协商其自己的ContentSize。

应设置ContentSizeForViewInPopover每个UIViewController中被重写WillShowViewController方法和设置的SizeF有呈现。

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(.., ..); 
    } 
}