monotouch.dialog styledstringelement调整单元格宽度

Joh*_*n D 7 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
Run Code Online (Sandbox Code Playgroud)

小智 1

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