以编程方式删除UITableView的标头并自动调整内容的大小以填充已删除的区域 [英] Programmatically remove the header of UITableView and automatically resizes the content to fill in the removed area

查看:87
本文介绍了以编程方式删除UITableView的标头并自动调整内容的大小以填充已删除的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过界面构建​​器在 UITableView 的标题部分添加了 UIButton ,并希望删除在某些情况下访问按钮。我曾尝试使用 .hidden = TRUE 属性,但它只是隐藏了视图中的按钮,后面留下了一个空白区域。如何以编程方式删除 UITableView 的标题,并让表格的内容自动调整大小以填充删除的标题区域?

I have added a UIButton in the header section of the UITableView via the interface builder and would like to remove the access to the button in certain cases. I have tried to use the .hidden = TRUE property but it just hides the button from the view, leaving a white space behind. How do I programmatically remove the header of UITableView and have the table's content automatically resizes to fill in the removed header area?

推荐答案

如果要删除表的标题视图,只需将myTable.tableHeaderView属性设置为nil即可。如果您拥有的实际上是一个节头,那么您需要从viewForHeaderInSection方法返回nil并调用[myTableView reloadData]

If you want to remove the table's header view, just set the myTable.tableHeaderView property to nil. If what you have is actually a section header, then you need to return nil from the viewForHeaderInSection method and call [myTableView reloadData]

这篇关于以编程方式删除UITableView的标头并自动调整内容的大小以填充已删除的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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