简体   繁体   English

UITableView部分页脚没有隐藏

[英]UITableView section footer not hiding

I have created a UITableView using the Interface Builder I have a section footer space there, I have designed my custom view as the section footer. 我使用Interface Builder创建了一个UITableView我有一个部分页脚空间,我将自定义视图设计为部分页脚。 But I want the section footer to be hidden initially and only load it after a service call. 但我希望最初隐藏部分页脚并仅在服务调用后加载它。

I have tried 我努力了

self.tableview.tablefooterview.hidden = YES
self.tableview.sectionFooterHeight = 0.0f

I have also set the height in delegate methods, but the table footer view is not hiding at all. 我还在委托方法中设置了高度,但是表页脚视图根本没有隐藏。 How do I hide the table footer view. 如何隐藏表格页脚视图。

check this Link for how to Hide footer view in UITableView 检查此链接以了解如何在UITableView中隐藏页脚视图

- (UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
{
    return [[UIView alloc] initWithFrame:CGRectZero];
}

Use UITableView delegate method :- 使用UITableView委托方法: -

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

    return 0;
}

Please try to set section footer value to more than 0(zero). 请尝试将部分页脚值设置为大于0(零)。 I tried to set it as 0.000001 and it works. 我试着把它设置为0.000001并且它有效。

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

return 0.000001;
}

Please try this code 请试试这段代码

- (void)viewDidLoad
{
    self.tableview.sectionHeaderHeight = 0.0;
    self.tableview.sectionFooterHeight = 0.0;
    self.tableview.tableHeaderView=[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableview.bounds.size.width, 0.01f)];
    self.tableview.tableFooterView=[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableview.bounds.size.width, 0.01f)];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0;
}

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

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