Xamarin iOS GetCell Streth CellView動的に
-
21-12-2019 - |
質問
Xamarin MobileCrmの例:
から私が適応した次のコードを持っています。[assembly: ExportCell(typeof(ListTextCell), typeof(ListTextCellRenderer))]
namespace Manager.iOS
{
class ListTextCellRenderer : TextCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableView tv)
{
var cellView = base.GetCell(item, tv);
cellView.TextLabel.Lines = 0;
return cellView;
}
}
}
.
TextLabelがデバイスの幅よりも多くのテキストを含んでいるときにテキストラベルが盗んだ/折り返し、したがって、それを使ってサイズが大きくなることをお勧めします。行を設定すると0。ラベルを折り返しますが、行の高さは同じままですので、すべての行は互いに重なっています。どのように行の高さも成長するのですか?
ありがとう
解決
あなたはあなたのTableview
にHasunevenrowsまたはRowHeightを設定する必要があるかもしれません。他のヒント
あなたの表ビューのソースでは、次の方法を上書きします。
public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
var text = new NSString(yourTextHere);
var size = text.StringSize(UIFont.FromName("FontName", fontSize), new SizeF(tableView.Frame.Width, 70)); // The 70 can be any number, the width is the important part
return size.Height + 16; // 16 is for padding
}
. 所属していません StackOverflow