【问题标题】:MonoTouch add footerMonoTouch 添加页脚
【发布时间】:2013-03-28 16:08:33
【问题描述】:

我正在尝试在表格视图中添加带有按钮的页脚视图。我在网上找到了这段代码

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 网站上也找不到任何合适的文档。

感谢您的帮助。

【问题讨论】:

  • GetSection 可能是您想自己编写的方法,或者是在您找到的示例中的其他地方实现的方法。
  • 我同意我必须编写 GetSection 方法,但我不知道我应该在其中写什么。其他世界它需要什么参数以及它返回什么。
  • 我们在这里缺少一些上下文。你在使用 MonoTouch.Dialog 吗?你在哪里找到的例子?
  • 我没有使用 MonoTouch.Dialog。我猜它与 MonoTouch.Dialog 有关,对吧?我想在没有 MonoTouch.Dialog 的情况下做到这一点......

标签: xamarin.ios table-footer


【解决方案1】:

您拥有的示例代码可能是 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-06
    • 2021-05-24
    • 2012-05-09
    • 2010-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多