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 中隐藏页脚视图


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01