monotouch.dialog styledstringelement调整单元格宽度

时间:2012-12-29 07:17:36

标签: c# xamarin.ios monotouch.dialog

我创建了一个MyStyledStringElement类,并创建了StyledStringElement和IElementSizing子类,试图控制一个styledstringelement的宽度。不幸的是,下面的代码只调整了getheight()中单元格的高度。是否有一个getWidth()方法,我可以使用或类似的东西来调整styledstringelement的宽度,使它看起来像一个UIButton?一如既往地感谢。

public override UITableViewCell GetCell (UITableView tv)
    {
        var cell = base.GetCell (tv);
        cell.AutosizesSubviews = false;
        //tv.TranslatesAutoresizingMaskIntoConstraints = false;
        cell.ClipsToBounds = false;
        cell.Frame.Width = 30;
        cell.Bounds.Width = 30;
        cell.Frame.Size = new System.Drawing.SizeF (30, 30);

        return cell;
    }


    #region IElementSizing implementation
    public float GetHeight (UITableView tableView, NSIndexPath indexPath)
    {
        //throw new NotImplementedException ();



        tableView.Frame.Width = 10;
        //tableView.Bounds.Width = 10;

        tableView.Frame.Height = 10;

        Console.WriteLine (tableView.ToString ());

        return 10;
    }
    #endregion

1 个答案:

答案 0 :(得分:1)

上次我看到这个,宽度由UITableView控制。您最好的选择是添加一个UIButton作为UITableViewCell的子项,并返回包含该按钮所需的高度。