我一直在努力隐藏页脚视图.我的问题是,当我单击按钮时,页脚中有一个按钮章节更新后.
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 中隐藏页脚视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!