MonoTouch添加页脚

时间:2013-03-28 16:08:33

标签: xamarin.ios table-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网站上也找不到任何适当的文档。

非常感谢帮助。

1 个答案:

答案 0 :(得分: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