Xamarin.ios 如何将Monotouch.Dialog.Element添加到UIView.AddSubview

Xamarin.ios 如何将Monotouch.Dialog.Element添加到UIView.AddSubview,xamarin.ios,monotouch.dialog,Xamarin.ios,Monotouch.dialog,简单来说,我想使用UIView.AddSubview向UIView添加Monotouch.Dialog.Element。为了实现这一点,我需要更改/创建什么 AMonoTouch.Dialog.Element基于UITableViewCell,而不是基于UIView 因此,元素应该是UITableView的一部分,不能简单地作为子视图添加到UIView 如果希望拥有类似于元素的ui视图,则必须创建一个从ui视图继承的自定义视图。在此视图中,您可以从所选元素的UITableViewCell内的视图

简单来说,我想使用UIView.AddSubview向UIView添加Monotouch.Dialog.Element。为了实现这一点,我需要更改/创建什么

A
MonoTouch.Dialog.Element
基于
UITableViewCell
,而不是基于
UIView

因此,
元素
应该是
UITableView
的一部分,不能简单地作为
子视图添加到
UIView

如果希望拥有类似于
元素的
ui视图
,则必须创建一个从
ui视图
继承的自定义视图。在此视图中,您可以从所选
元素
UITableViewCell
内的
视图
中创建您喜欢的行为

编辑:基于MultiLineElement的基本示例

public class MyView : UIView
{
  private string Caption { get; set; }          
  private string Text { get; set; }

  public View(string caption, string text) : base()
  {
    Opaque = true;
    BackgroundColor = UIColor.Clear;
    Update(caption, text);
  }

  public void Update(string caption, string text)
  {
    Caption = caption;
    Text = text;

    SetNeedsDisplay();
  }

  public override void Draw(RectangleF frame)
  {
    var bounds = Bounds;
    var captionFont = UIFont.BoldSystemFontOfSize(12f);
    var textFont = UIFont.SystemFontOfSize(10f);
    var width = Bounds.Width;

    if (string.IsNullOrWhiteSpace(Caption) == false)
    {
      // Caption, black
      UIColor.Black.SetColor();
      width = Bounds.Width / 2;
      var captionHeight = 
        StringSize(Caption, captionFont, width, UILineBreakMode.TailTruncation).Height;
      var captionOffset = textFont.PointSize - captionFont.PointSize;
      DrawString(Caption, new RectangleF(0, captionOffset, width, captionHeight),
        captionFont, UILineBreakMode.TailTruncation, UITextAlignment.Right);
    }

    // Text, dark gray
    UIColor.DarkGray.SetColor();
    var textHeight = 
      StringSize(Text, textFont, width, UILineBreakMode.WordWrap).Height;
    DrawString(Text, new RectangleF(Bounds.Width - width, 0, width, textHeight), 
      textFont, UILineBreakMode.WordWrap);
  }
}

谢谢你的回答,虽然你在最后一段中描述的解决方案我不清楚-你能提供一个简单的例子吗?我将在几个小时内尝试提供一个例子。我添加了一个非常基本的例子,但希望能让你开始。