I have a UITableView that has a header view that I want to use to display content. When no content exists, I want to hide the header view (which is a UIView class) and have the TableView Cells slide to the top of the view.
It's like
____________
| ---------- |
| | | |
| | header | |
| | | |
| ---------- |
| ---------- |
| | cell | |
| ---------- |
| |
When I call
[theHeaderView setHidden:YES]
The content in the header view disappears but the cells of my TableView remain halfway down the screen to where the header had pushed them. so i wind up with:
____________
| |
| EMPTY |
| SPACE |
| |
| |
| ---------- |
| | cell | |
| ---------- |
| |
What is the proper way to hide the header view and have the table view cells move to the top of the screen?
and then i want to reopen my header later on with new content and push the cells down again.
thanks!
You need to change the tableView:heightForHeaderInSection:
rather than just making the header view hidden. I don't recall if this will animate when you reload the table ( reloadSections:withRowAnimation:
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.