monotouch.dialog styledstringelement adjust cell width
Asked Answered
M

1

7

I create my a class MyStyledStringElement and subclass StyledStringElement and IElementSizing in an attempt to control the width of a styledstringelement. Unfortunately, the code below only resizes the height of the cell in getheight(). Is there a getWidth() method that I can use or something similar to adjust the width of a styledstringelement so that it looks the same as a UIButton? As always thanks in advance.

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
Machuca answered 29/12, 2012 at 7:17 Comment(0)
D
1

Last time I looked at this, the width is controlled by the UITableView. Your best bet would be to add a UIButton as a child of the UITableViewCell and return the height that you need to contain the button.

Decosta answered 10/2, 2013 at 2:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.