【问题标题】:Monotouch dialog multiline element height not growingMonotouch对话框多行元素高度没有增长
【发布时间】:2013-02-04 13:55:15
【问题描述】:

我有一个简单的自定义多行元素,我将其换行模式设置为自动换行,并将行属性设置为 7。我的文本似乎可以很好地换行,但单元格高度保持不变,因此文本扩展了边界的细胞。我尝试增加单元格的框架并覆盖 GetHeight,但在这两种情况下似乎都不起作用。另外,我的 GetHeight 似乎没有被调用。

任何人都面临类似的事情?或者对可能出现的问题有什么想法?

public class DisclaimerMultilineElement : MultilineElement
{
    public DisclaimerMultilineElement (string caption) : base(caption)
    {
    }

    public DisclaimerMultilineElement (string caption, string value) : base(caption, value)
    {
    }

    public DisclaimerMultilineElement (string caption, NSAction tapped) : base(caption, tapped)
    {
    }

    public override float GetHeight (UITableView tableView, NSIndexPath indexPath)
    {
        var ht = base.GetHeight (tableView, indexPath);
        //return base.GetHeight (tableView, indexPath);
        return 400.0f;
    }

    public override UITableViewCell GetCell (MonoTouch.UIKit.UITableView tv)
    {
        UITableViewCell cell = base.GetCell (tv);
        var frame = cell.Frame;
        frame.Height = 300f;
        //cell.Frame = new System.Drawing.RectangleF(frame.X, frame.Y, frame.Width, frame.Height);
        cell.BackgroundColor = UIColor.Clear;
        cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (12);
        cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
        cell.TextLabel.Lines = 7;
        cell.TextLabel.TextAlignment = UITextAlignment.Left;
        cell.TextLabel.Text = Value;
        return cell;
    }
}

【问题讨论】:

    标签: c# ios xamarin.ios monotouch.dialog xamarin.mobile


    【解决方案1】:

    确保在您的 Root 元素中将 UnevenRows 设置为 true

    【讨论】:

      【解决方案2】:

      您需要在您的UITableViewSource 中覆盖GetHeightForRow 并返回适当的高度。

      【讨论】:

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