2011-11-15 126 views
4

上的任何位置定义节中讨论这样的事情:Monotouch对话框。在屏幕

new RootElement ("Root"){ 
          new Section ("Section A") { 
          new EntryElement("Element in A") 
          } 
          new Section ("Section B") { 
          new EntryElement("Element in B") 
          } 
} 

和Monotouch.Dialog将创建你的TableView有两个部分。现在我想让第二部分位于第一部分的下方,而不是在屏幕的最下方。我怎样才能做到这一点?

+0

我认为你必须破解MT.D源代码才能做到这一点。这是相当极端的情况,我不希望MT.D能够处理。 – Jason

回答

3

看来你可以通过定义为部分空HeaderView欺骗Monotouch.Dialog。它将扩大部分之间的空间。类似这样的:

lastSection.HeaderView = new UIView(new RectangleF(0,0,0,80)); 

我不确定这是否正确。为我工作。

1

我不相信MonoTouch.Dialog可以做到这一点。您将需要:

  1. 定义一个大的透明UITableViewCell子类。
  2. 定义一个'Element'子类并覆盖它的GetCell(...)方法来提供您在上面分类的单元格。
  3. 在上面的元素上实现IElementSizing并实现GetHeight(...)来描述第一个和最后一个单元格之间的透明单元格的高度。
  4. 使用您的顶级EntryElement和底部EntryElement部分之间的Element子类创建一个空白部分。

生成的代码看起来是这样的:

this.Root = new RootElement ("Root") { 
    new Section ("Section A") { 
     new EntryElement("Element in A") 
    } 
    new Section("") { 
     new EmptyElement() 
    } 
    new Section ("Section B") { 
     new EntryElement("Element in B") 
    } 
}; 
+0

实际上我用定义节的HeaderView来欺骗MTD,像这样:lastSection.HeaderView = new UIView(new RectangleF(0,0,0,80)); – Agzam

+0

@Agzam不错的做法。 – Anuj