Hide footer view in UITableView(在 UITableView 中隐藏页脚视图)
问题描述
我一直在努力隐藏页脚视图.我的问题是,当我单击按钮时,页脚中有一个按钮章节更新后.
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 中隐藏页脚视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UITableView 中隐藏页脚视图


基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01