【问题标题】:Monotouch Dialog OwnerDrawnElement - Height Size not being calledMonotouch Dialog OwnerDrawnElement - 未调用高度大小
【发布时间】:2014-06-02 17:16:44
【问题描述】:

我正在尝试从 OwnerDrawnElement 继承(如文档中所述)。一切似乎都在工作,除了高度方法从未被调用,所以我无法设置单元格的高度。高度方法永远不会被调用(断点永远不会命中)。我试图强制重新实现 IElementSizing 并将该方法再次实现为新方法。同样,这也没有受到打击。这是精简的代码

public class CustomDrawElement : OwnerDrawnElement, IElementSizing
    {
        public CustomDrawElement (UITableViewCellStyle style, string cellIdentifier) : base (style, cellIdentifier)
        {

        }

        #region implemented abstract members of OwnerDrawnElement

        public override void Draw (System.Drawing.RectangleF bounds, MonoTouch.CoreGraphics.CGContext context, MonoTouch.UIKit.UIView view)
        {
            UIColor.Blue.SetFill ();
            context.FillRect (bounds);
        }

        public override float Height (System.Drawing.RectangleF bounds)
        {
            return 220f;
        }

        #endregion

        public new float GetHeight (UITableView tableView, NSIndexPath indexPath) {
            return 220f;
        }
    }

创建对象时,我仅用于测试目的:

var e = new CustomDrawnElement(UITableViewCellStyle.Default, "myKey");

我目前使用的是最新的 Xamarin Studio 3。

我已经阅读了关于这门课的所有问题,似乎没有人遇到过这个问题。不确定是否是由于引入了新错误的新 3 版本。

【问题讨论】:

    标签: xamarin monotouch.dialog xamarin-studio


    【解决方案1】:

    好的,经过大量研究,我找到了答案。为了调用自定义高度方法,您需要在为 MonoDialog 创建的 rootElement 上设置 UnevenRows = true。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-28
      • 2019-02-03
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多