如何隐藏UITableView标题然后重新显示? [英] How to hide UITableView Header and then have it Reappear?

查看:105
本文介绍了如何隐藏UITableView标题然后重新显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

偶尔我的UITableView中有一部分没有包含在该部分中的单元格。那么在这种情况下,由于上部没有单元格,所以有两个标题相互重叠。我试图弄清楚如何暂时隐藏上部标题,然后在我稍后返回页面时重新显示。



我可以返回零为 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 然后强制它在viewWill中再次被调用。

另外,如果我使用 [self.tableView reloadData] 重新加载数据,那么如何返回标准UITableView标题的高度?

解决方案

当您必须隐藏标题时

  [tableView setContentOffset:CGPointMake(0,44)animated:YES]; 

当您必须显示标题时

  [tableView setContentOffset:CGPointMake(0,0)animated:YES]; 


I occasionally have a section of my UITableView where there are no cells contained in that section. In that case then, there are two headers on top of each other since there are no cells in the upper section. I'm trying to figure out how I can temporarily hide that upper header and then have it reappear when I come back to the page later.

Can I return zero for -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section and then force it to be called again in viewWillAppear somehow??

Also, if I reload the data using [self.tableView reloadData], how do you just return the standard height for a UITableView Header?

解决方案

When you have to hide header

[tableView setContentOffset:CGPointMake(0, 44) animated:YES];

When you have to show header

[tableView setContentOffset:CGPointMake(0, 0) animated:YES];

这篇关于如何隐藏UITableView标题然后重新显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆