Vra

I've got the following code that i've adapted from the Xamarin MobileCRM example:

[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 wanting to have it that the TextLabel will stetch/wrap when it contains more text than the width of the device and therefore the rows will grow in size with it. When I set the Lines = 0; it wraps the label but the row height stays the same so every row just overlaps each other. How do I grow the row height as well?

Thanks

Was dit nuttig?

Oplossing

You may have to set HasUnevenRows or the RowHeight on your TableView

Ander wenke

In your tableView source you will want to override the following method

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
 }
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top