New*_*der 19 iphone footer uitableview ios5
我一直在努力隐藏footerview.我的问题是,当我单击按钮时,我在页脚中有一个按钮,下面将添加一个部分作为最后一部分,按钮也将转移到新创建的部分,现在我想隐藏表格上一部分中的页脚更新部分后.
footerView.hidden = YES
Run Code Online (Sandbox Code Playgroud)
我在按钮动作中使用了它,但它不起作用.
Sha*_* TK 42
有四种解决方案.他们是,
解决方案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];
}
Run Code Online (Sandbox Code Playgroud)
解决方案2:
您可以通过尺寸选项卡下的界面构建器设置页脚/标题高度.
解决方案3:
设置contentInset属性.
self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0);
Run Code Online (Sandbox Code Playgroud)
它用于使顶部和底部接触边缘.
解决方案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)];
}
Run Code Online (Sandbox Code Playgroud)
sha*_*irv 16
这应该做到这一点
tableView.tableFooterView.hidden = YES;
Run Code Online (Sandbox Code Playgroud)
小智 8
这可以通过实现委托方法来实现
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
Run Code Online (Sandbox Code Playgroud)
参考@J.Hong 的回答,Swift4版本(iOS 11.3):
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
Run Code Online (Sandbox Code Playgroud)
与@Tim Newton 的回答相比:
titleForFooterInSectionCGFloat.leastNormalMagnitude-> .leastNonzeroMagnitude(更 Swifty IMO)| 归档时间: |
|
| 查看次数: |
33698 次 |
| 最近记录: |