2013-03-28 26 views
0

我想在我的表格視圖中添加一個帶有按鈕的頁腳視圖。我發現這個代碼在網上MonoTouch add footer

public override UIView GetViewForFooter(UITableView tableView, int sectionIndex) 
{ 
    // Write a method to get the proper Section via the sectionIndex 
    var section = GetSection(sectionIndex); 
if (section != null) 
{ 
    if (section.FooterView == null && !string.IsNullOrEmpty(section.FooterText)) 
    { 
      // Create your FooterView here 
     section.FooterView = CreateFooterView(tableView, section.FooterText); 
    } 

    return section.FooterView; 
} 

return null; 
} 

我不知道什麼GetSection方法是什麼?我有錯誤「名稱GetSection在當前上下文中不存在」。

我在MonoTouch網站上也找不到任何適當的文檔。

幫助表示讚賞。

+0

GetSection可能是您自己編寫的一種方法,或者是您找到的示例中某處實現的方法。 – NilsH

+0

我同意我必須寫GetSection方法,但我不知道我應該寫什麼。其他世界需要什麼參數以及返回的內容。 – User382

+0

我們在這裏錯過了一些上下文。你在使用MonoTouch.Dialog嗎?你在哪裏找到了這個例子? – NilsH

回答

0

您擁有的示例代碼可能是一個MonoTouch.Dialog示例。如果你不使用MonoTouch.Dialog,只需從這個方法返回一個合適的UIView。喜歡的東西:

public override UIView GetViewForFooter(UITableView tableView, int sectionIndex) { 
    var myFooter = new UIView(); // Or some other class extending UIView, depending on what you want to do 
    // Add SubViews and style the view 
    return myFooter; 
} 

如果您在表中查看多個部分,您可以通過採取sectionIndex參數考慮爲每個部分不同的頁腳。有關更多信息,請檢查documentation

+0

感謝NilsH它工作! – User382