【问题标题】:Monotouch.Dialog: IElementSizing not being usedMonotouch.Dialog:未使用 IElementSizing
【发布时间】:2011-05-10 07:08:48
【问题描述】:

我有一个自定义元素类,它只在我旋转设备时调整行的大小。在初始显示时,不会调整行的大小。

public class MultiImageElement : Element, IElementSizing

实现IElementSizing接口:

    #region IElementSizing implementation
    public float GetHeight (UITableView tableView, NSIndexPath indexPath)
    {
        return 78;
    }
    #endregion

但是,这永远不会被调用,并且行高保持默认大小。

我在循环中将元素添加到我的根:

for (int i = 0; i < secFolder.Rows; i++)
{
   sec.Add (new MultiImageElement (secFolder.ThumbnailPathsForRow (i), imageSize));
}
this.Root.Add (sec);

【问题讨论】:

    标签: xamarin.ios monotouch.dialog


    【解决方案1】:

    我找到了解决办法。

    要让Monotouch.Dialog 实现IElementSizing,必须将部分和元素添加到本地“myRoot”变量中。

    构建完成后,将Dialog's Root设置为那个。

    var myRoot = new Root();
    MakeElements()
    this.Root = myRoot;
    

    这行得通。

    【讨论】:

      【解决方案2】:

      另一种解决方案是自定义 DialogViewController,然后将 Root.UevenRows 设置为 true:

      公共类 CustomViewController : DialogViewController { 公共 CustomViewController(RootElement 根):基础(根) { Root.UnevenRows = true; ... } ... }

      【讨论】:

        【解决方案3】:

        可能不相关,但我碰巧没有向我触发初始旋转设备事件。因此,我实现了该标志并启动了一个计划选择器,以便在应用启动时调用,以确保调用 ShouldAutorotate... 并在需要时为我执行布局。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多