我正在尝试在UIViewElement中显示UITextView。我希望Element可以根据文本调整大小。

我希望能够做这样的事情...

 UITextView textView = new UITextView();



    textView.Font = UIFont.SystemFontOfSize(15);
       var stringSize = textView.StringSize(someArbitraryText,
                                            textView.Font,
                                            new SizeF(320, 2000),
                                            UILineBreakMode.WordWrap);

       textView.Bounds = new RectangleF(0,0,stringSize.Width, stringSize.Height);
       textView.Center = new PointF(stringSize.Width/2, stringSize.Height/2);
       textView.Editable = false;
       textView.DataDetectorTypes = UIDataDetectorType.All;
       textView.Text = someArbitraryText;
       textView.ScrollEnabled = false;





   root.Add(
      new Section("My Section:")
      {

         new UIViewElement("My Caption:", textView, false),

      });


这使我接近,但UITextView的部分保留在Element边界上。我希望UIViewElement的大小足以适合我的自定义视图。有没有一种方法而无需进入并修改UIViewElement源?

最佳答案

我相信在您的Element中添加一个IElementSizing的实现,方法是:

浮动GetHeight(UITableView tableView,NSIndexPath indexPath);

在此方法中,返回元素的高度。即TextView.Bounds.Height +10。我在顶部和底部添加了+ 10作为边框。

关于iphone - 设置UIViewElement的边界-Monotouch.Dialog,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5504077/

10-12 02:48