简体   繁体   中英

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. 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

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

Use UITableView delegate method :-

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

    return 0;
}

Please try to set section footer value to more than 0(zero). I tried to set it as 0.000001 and it works.

- (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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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