C# 单触式对话框多行元素高度未增长
我有一个简单的自定义多行元素,我将其换行模式设置为wordwrap,lines属性设置为7。我的文本似乎包裹得很好,但单元格高度保持不变,因此文本扩展了单元格的边界。我已经尝试增加单元格的帧并覆盖GetHeight,但在这两种情况下似乎都不起作用。而且,我的GetHeight似乎还没有被调用 有人面临类似的情况吗?或者有没有关于这个问题的想法C# 单触式对话框多行元素高度未增长,c#,ios,xamarin.ios,monotouch.dialog,xamarin.mobile,C#,Ios,Xamarin.ios,Monotouch.dialog,Xamarin.mobile,我有一个简单的自定义多行元素,我将其换行模式设置为wordwrap,lines属性设置为7。我的文本似乎包裹得很好,但单元格高度保持不变,因此文本扩展了单元格的边界。我已经尝试增加单元格的帧并覆盖GetHeight,但在这两种情况下似乎都不起作用。而且,我的GetHeight似乎还没有被调用 有人面临类似的情况吗?或者有没有关于这个问题的想法 public class DisclaimerMultilineElement : MultilineElement { public Discl
public class DisclaimerMultilineElement : MultilineElement
{
public DisclaimerMultilineElement (string caption) : base(caption)
{
}
public DisclaimerMultilineElement (string caption, string value) : base(caption, value)
{
}
public DisclaimerMultilineElement (string caption, NSAction tapped) : base(caption, tapped)
{
}
public override float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
var ht = base.GetHeight (tableView, indexPath);
//return base.GetHeight (tableView, indexPath);
return 400.0f;
}
public override UITableViewCell GetCell (MonoTouch.UIKit.UITableView tv)
{
UITableViewCell cell = base.GetCell (tv);
var frame = cell.Frame;
frame.Height = 300f;
//cell.Frame = new System.Drawing.RectangleF(frame.X, frame.Y, frame.Width, frame.Height);
cell.BackgroundColor = UIColor.Clear;
cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (12);
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 7;
cell.TextLabel.TextAlignment = UITextAlignment.Left;
cell.TextLabel.Text = Value;
return cell;
}
}
您需要在
UITableViewSource
中覆盖GetHeightForRow
,并返回适当的高度。确保在根元素中将行设置为true