我有以下代码,我从Xamarin Mobilecric示例调整了:

[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;
    }               
}
}
.

im希望使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
 }
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top