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

如何在iOS Xcode 6.1中从表视图中删除页眉和页脚,ios,uitableview,Ios,Uitableview,我无法从分组表视图中删除页眉和页脚。我使用的是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.

我无法从分组表视图中删除页眉和页脚。我使用的是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];

}
把它们设为零就行了

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

对于未来返回零高度的游客,heightForHeaderInSection也将获得相同的结果

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 0
}
对于swift,请使用此


self.tableView.tableHeaderView=UIView()

[这是stackoverflow的答案][1][1]:共享您的屏幕快照,没有指定为默认的页眉和页脚。你们到底想删除什么?根据你们的代码你们创建了它们,而问题是如何删除。。。