【问题标题】:how to remove header and footer from a table view in iOS Xcode 6.1如何从 iOS Xcode 6.1 中的表格视图中删除页眉和页脚
【发布时间】:2020-01-16 13:56:40
【问题描述】:

我无法从分组表视图中删除页眉和页脚。我使用的是Xcode 6.1,我的代码如下。

- (void)viewDidLoad {
    [super viewDidLoad];

    arr=[[NSArray alloc]initWithObjects:@"Facebook",@"Twitter",@"Linkedin", @"Google+",@"App.net", nil];
    imgView=[[NSArray alloc]initWithObjects:@"fb.png",@"tw.png",@"ln.png",@"em.png", @"em.png", nil];

    self.tableView.layer.borderWidth=1.0;

    self.tableView.tableFooterView=[[UIView alloc]initWithFrame:CGRectZero];
    self.tableView.tableHeaderView=[[UIView alloc]initWithFrame:CGRectZero];

}

【问题讨论】:

  • [这是来自stackoverflow的答案][1] [1]:stackoverflow.com/a/5164520/3102255
  • 分享您的屏幕截图,默认情况下没有指定页眉和页脚。你到底想删除什么?
  • 根据您的代码创建它们,而问题询问如何删除...

标签: ios uitableview


【解决方案1】:

只需将它们设置为 nil

self.tableView.tableHeaderView = nil;
self.tableView.tableFooterView = nil;

【讨论】:

    【解决方案2】:

    对于使用 heightForHeaderInSection 返回零高度的未来访问者也将获得相同的结果。

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 0
    }
    

    【讨论】:

      【解决方案3】:

      为了快速,使用这个

      self.tableView.tableHeaderView = UIView()

      【讨论】:

        猜你喜欢
        • 2011-02-15
        • 1970-01-01
        • 2013-05-11
        • 2012-01-03
        • 2015-10-01
        • 1970-01-01
        • 2011-09-16
        相关资源
        最近更新 更多