How can I do the following in a UIViewController (containing a tableview as a subview)
I initially have a UIViewController showing a preview section (UIView)
Yes,You can use "tableView:viewForHeaderInSection".
Or you can just do these steps:
1. Disable scrolling of the tableView.
2. Set height constraint to the tableView and a IBOutlet connected to it.
3. Before you reload the data, calculate the table height. heightConstraint.constant = (heightOfTheSingleTableViewCell) * numOfRows
You will have to embed your UITableView inside of a UIScrollView that has the size of the screen minus the navigation bar. Set the UIScrollViews background to clearColor to allow your content above the UITableView to remain visible.
i have a solution for you,
use only tableView is enough
make the "Preview View" as the HeaderView of your tableView
make the "Search Bar" as the Section Header View of your tableView
you can make it perfectly :)
No need for anything fancy or custom, use a UITableView
and set your preview pane to be the tableHeaderView
and your search field to be the section header using tableView:viewForHeaderInSection:
in your UITableViewDelegate
.
The table header will scroll off the top during scroll event. Section headers float and stay visible the whole time that section if visible. If you only have 1 section, then the section header will be there the whole time.
scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
It can not scroll because contentSize is not large enough. You need to increase the length to total length of your content that are on top of the scrollView.