问题描述
我一直在努力隐藏页脚视图。我的问题是,当我单击按钮时,我在页脚中有一个按钮,下面将添加一个部分作为最后一部分,按钮也将转移到新创建的部分,现在我想隐藏页面上一部分中的页脚更新部分后。
I have been working to hide the footerview for while. My problem is I have a button in footer when I click the button one section will be added below as the last section and the button too will shift to the newly created section and now I want to hide the footer in the previous section of the table after the update of sections.
footerView.hidden = YES
我在按钮操作中使用了它,但它无效。
I used this in the button action but its not working.
推荐答案
有四种解决方案。他们是,
There are four solutions. They are,
解决方案1:
tableView.sectionHeaderHeight = 0.0;
tableView.sectionFooterHeight = 0.0;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger )section {
return 1.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger )section {
return 1.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
解决方案2:
您可以通过尺寸标签下的界面构建器设置页脚/标题高度。
You can set the footer/header height via interface builder under the size tab.
解决方案3:
设置 contentInset 属性。
self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0);
它用于使顶部和底部触摸边缘。
It is used to make the top and bottom touch the edge.
解决方案4:
执行以下操作,根据您的情况设置值。 0.0将不被接受。较低的值应为1.0。
implement the below, set the values as per your condition. 0.0 will not be accepted. The lower value should be 1.0.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger )section {
if(section == 0) {
return 6;
} else {
return 1.0;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger )section {
return 5.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}
这篇关于在UITableView中隐藏页脚视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!