Peter Warbo
Peter Warbo

Reputation: 11700

Grouped UITableView sticky header/footer sections

Is it possible to have sticky header/footer sections for a UITableView that is grouped?

If not, is there an alternative way of achieving this?

Upvotes: 2

Views: 1861

Answers (1)

Tieme
Tieme

Reputation: 65389

This is not possible out of the box.

You'll have to create your own UITableViewController by subclassing a UIViewController.

This answer provides some advice on a sticky footer.. for a sticky header and footer you'll need to:

  1. Have your class inherit from UIViewController (instead of UITableViewController)
  2. Have your class implement the UITableViewDelegate and UITableViewDataSource protocols
  3. Implement the UITableViewDelegate and UITableViewDataSource methods in your class (e.g. cellForRowAtIndexPath:, didSelectRowAtIndexPath:, etc)
  4. In IB, add a UITableView as a subview to your view controller's view
  5. Resize and move the frame of the UITableView to allow space at the bottom and the top for your header & footer
  6. Set the delegate and datasource properties of the table view you just added to be your viewcontroller class
  7. Add 2 subviews to your view controller's view one for your header and one for your footer.

Now the footer and header view are not part of the UITableView and won't scroll.

Upvotes: 1

Related Questions