I have a table view controller, and I drag-and-drop an additional UIView
on a storyboard to make a header, it becomes a subview of UITableView
.
I do not make it an "official" section header with viewForHeaderInSection:
and friends (I'll explain why), it's just a subview of a table view, which appears on top of the table, alongside internal table view wrapper and refresh control views in the hierarchy of views.
The hierarchy looks like this:
UITableView 0,0 320x455
UIRefreshControl 0,0 320x60
UITableViewWrapperView 0,0 320x455
cell 0,190 320x44
cell 0,146 320x44
cell 0,102 320x44
cell 0, 58 320x44
custom UIView 0,0 320x58
Now, the header view is working great... until I want to resize it. The idea is, the header view has a text field, which, when focused, causes additional form fields to expand under it, pushing table cells down.
The problem is that I have little control over laying out of cells. While resizing the custom view (by changing its frame), it overlays the table wrapper view.
So, why don't I just make it a section header view and resize it via heightForHeaderInSection:
? The problem is that when a text field is focused or typed into, I need to call [self.tableView reloadData]
to refresh the data in the table (search-as-you-type kind of thing), which reloads the headers too and makes text field lose focus.
So to sum it up,
- How do I actually make a table header that can dynamically resize and push down table cells?
- How can I keep focus of the text view inside the table header while reloading said table?