代码之家  ›  专栏  ›  技术社区  ›  Mustafa

重绘或重设表视图页眉和/或页脚

  •  1
  • Mustafa  · 技术社区  · 15 年前

    有别的办法吗 [tableView reloadData] 刷新表格页眉和/或页脚?关于这两个方面:

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
    OR
    - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
    

    例如,我在页脚显示一个小摘要。当行中的数据更改时,影响也应该反映在页脚中。

    1 回复  |  直到 15 年前
        1
  •  0
  •   Ali    15 年前

    创建UILabel并将其设置为节页眉/页脚。随时更新UILabel。

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
        return sectionFooterView;
    }
    
    - (void)viewDidLoad {
            // create sectionFooterView in Interface Builder, change the frame here
            // use Font-size:15 , BG-Color: clearColor , text-Color: RGB=(97,105,118) 
            // and Text-alignment:Center to look like table view's original footer
        sectionFooterView.frame = CGRectMake(0, 10, 320, 12);
    }
    
    - (void)changeFooter {
            sectionFooterView.text = @"Footer";
    }
    
    推荐文章