2012-12-29 10 views
7

私はMyStyledStringElementクラスを作成し、StyledStringElementとIElementSizingをサブクラス化して、スタイル付きストリング要素の幅を制御します。残念ながら、以下のコードはgetheight()内のセルの高さのサイズを変更するだけです。私が使用できるgetWidth()メソッドや、スタイリングされたストリング要素の幅を調整してUIButtonと同じように見えるものがありますか?常に前もって感謝します。monotouch.dialog styledstringelementセル幅を調整する

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

最後に、これを見て、幅はUITableViewによって制御されます。あなたの最善の策は、UITableViewCellの子としてUIButtonを追加し、ボタンを格納するのに必要な高さを返すことです。

関連する問題