Monotouch对话框多行元素高度不增长

时间:2013-02-04 13:55:15

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

我有一个简单的自定义多行元素,其换行模式我已设置为wordwrap,而line属性我设置为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;
    }
}

2 个答案:

答案 0 :(得分:7)

确保根元素中的UnevenRows设置为true

答案 1 :(得分:2)

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

相关问题