2011-11-15 124 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