2011-09-28 22 views
1

我在UITableView中顯示5至8個項目。但Separator行也顯示空單元格。這個空單元沒有價值。爲什麼Separator行顯示在這些空單元上?我在Interface Builder中選擇Separator值爲Single Line。如何使用MonoTouch在UITableView中顯示Separator行當前顯示的單元格?如何使用MonoTouch顯示當前在UITableView中顯示單元格的分隔線?

看看截圖。我在UITableView中顯示了5個項目。但分隔符顯示UITableView的所有單元格。我需要在UITableView中使用分隔線。

look at the screen shot

+0

你能顯示你使用的代碼嗎?你可能也想看看MonoTouch.Dialogs,它使得使用表格變得如此簡單@ https://github.com/migueldeicaza/MonoTouch.Dialog – poupou

+0

@poupou:我已經使用過[例子代碼](http:// sabonrai .wordpress.com/2009/08/28/MonoTouch的樣本代碼-的UITableView /)。 – bharath

回答

1

如果我理解正確的話,你想從你UITableView消除空白單元格? 如果是的話,這樣做是爲了清除以下數據的空白單元格/空間:

/// <summary> 
/// Removes empty lines below a tableview. Attention: calls the table's delegate implicitly, so make sure it is initialized. 
/// </summary> 
public static void ClearEmptyTableViewSpacers (UITableView oTableView) 
{ 
    UIView oViewSpacerClear = new UIView (new System.Drawing.RectangleF (0, 0, oTableView.Frame.Width, 10)); 
    oViewSpacerClear.BackgroundColor = UIColor.Clear; 
    oTableView.TableFooterView = oViewSpacerClear; 
} 
+0

我用屏幕截圖更新了我的問題。看看我的問題。 – bharath

+0

然後我的代碼將修復它。在初始化TableView後,只需將它放在ViewDidLoad()中。試試吧。 – Krumelur

+0

Krumelur,美麗。 :)工作正常。 – bharath

1

這是不可能說一個分隔符行僅用於特殊細胞。 tableview總是爲UITableView的整個高度繪製分隔線。

使其成爲可能的唯一方法是將TableView SeperatorColor設置爲透明並在單元格內繪製分隔線。但我認爲這是大量名單上嚴重失效的表現。

相關問題