简体   繁体   English

如何从 iOS Xcode 6.1 中的表格视图中删除页眉和页脚

[英]how to remove header and footer from a table view in iOS Xcode 6.1

I am unable to remove the header and footer from the grouped table view.我无法从分组表视图中删除页眉和页脚。 I am using Xcode 6.1 and my code is as follows.我使用的是 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];

}

Just set them to nil只需将它们设置为零

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

For future visitors returning zero height with heightForHeaderInSection will also get the same results.对于未来使用 heightForHeaderInSection 返回零高度的访问者也将获得相同的结果。

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

For swift, use this为了快速,使用这个

self.tableView.tableHeaderView = UIView() self.tableView.tableHeaderView = UIView()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM