Xamarin iOS GetCell Stretch Cellview dinámicamente
-
21-12-2019 - |
Pregunta
Tengo el siguiente código que he adaptado del ejemplo de 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;
}
}
}
Estoy deseando tenerlo en que el Label de Textlabel se envuelva cuando contenga más texto que el ancho del dispositivo y, por lo tanto, las filas crecerán en tamaño con él.Cuando establezco las líneas= 0;Envuelve la etiqueta, pero la altura de la fila permanece igual, por lo que cada fila se superpone entre sí.¿Cómo crezco también la altura de la fila?
gracias
Solución
Es posible que tenga que configurar HasannevenRows o Rowheight en su TablaView
Otros consejos
En su fuente de Tableview, querrá anular el siguiente método
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
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow