我一直在努力隐藏页脚 View 一段时间。我的问题是我的页脚中有一个按钮,当我单击该按钮时,将在下面添加一个部分作为最后一部分,并且该按钮也将转移到新创建的部分,现在我想隐藏表的前一部分中的页脚更新章节后。
footerView.hidden = YES
我在按钮操作中使用了它,但它不起作用。
最佳答案
有四种解决方案。他们是,
解决方案 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:
您可以通过尺寸选项卡下的界面构建器设置页脚/页眉高度。
解决方案 3:
设置contentInset属性。
self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0);
用于使顶部和底部接触边缘。
解决方案 4:
实现以下内容,根据您的条件设置值。 0.0 将不被接受。较低的值应为 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)];
}
关于iphone - 在 UITableView 中隐藏页脚 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11445301/