【问题标题】:How to access footer or header view of specific section in UITableView?如何访问 UITableView 中特定部分的页脚或页眉视图?
【发布时间】:2011-09-17 19:39:03
【问题描述】:

我在创建表格时添加页眉和页脚视图。 我想要做的是以编程方式动态地更改页脚的内容。 有没有标准的方法来获取 UIView 作为页脚?

我知道有一种方法是添加UIView 属性并在- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 中创建脚时分配脚UIView 但我想知道是否有更好的方法来做到这一点。

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    您可以在创建自定义部分页脚视图时对其进行标记,例如在tableView:viewForFooterInSection: 中,如下所示:

    mySectionFooterView.tag = kMySectionFooterViewTag;
    

    kMySectionFooterViewTag 可以是任何你喜欢的NSInteger

    要从程序的其他部分访问mySectionFooterView,您可以使用:

    mySectionFooterView = [myTableView viewWithTag:kMySectionFooterViewTag];
    

    myTableViewUITableView,包含您的自定义部分页脚视图。使用UITableViewController 时,您通常可以将myTableView 作为self.tableView 访问。

    请注意,这种方法可能会考虑性能,因为viewWithTag: 将搜索myTableView 的整个视图层次结构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-20
      • 2011-02-12
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      相关资源
      最近更新 更多