iphone - 在 UITableView 中隐藏页脚 View

标签 iphone uitableview ios5 footer

我一直在努力隐藏页脚 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/

相关文章:

swift - iOS11中有没有办法指定UIContextualAction的宽度?

swift - UITableViewCell 可选图像

ios5 - 如何在 ios5 中自定义 UIBarButtonItem

ios - AFNetworking http 客户端不发送 JSON 参数

ios - 在 ios uitableview 中间歇性地获取 json 提要失败

iphone - 无法删除或停止 AVPlayer

ios - CLLocationManager + 对 CLBeaconRegion 的监控

iphone - 从 MySQL 或其他数据库存储和检索数据

iphone - 我将如何在文件上添加/维护校验和?

ios - 从复杂的 ScrollView 页面移动时崩溃