在 UITableView 中隐藏页脚视图

Hide footer view in UITableView(在 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 中隐藏页脚视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
HTTPS request using volley(使用 volley 的 HTTPS 请求)