Skip to content

Extension for the UITableView that allows a user to select the headerView of tableView and call back, can be used to make a foldable tableView.

Notifications You must be signed in to change notification settings

kenny1269/UITableViewDelegate_HeaderViewSelection

Repository files navigation

UITableViewDelegate_HeaderViewSelection

Extension for the UITableView that allows a user to select the headerView of tableView and call back, can be used to make a foldable tableView.

Getting start

  • Include UITableView+HeaderView category and UITableViewDelegate_HeaderViewSelection protocol.
  • UITableView's delegate should implement the UITableViewDelegate_HeaderViewSelection protocol.
  • When implementing the method tableView:viewForHeaderInSection:, call the category method headerView:forSection using the returning headerView as the parameter.

How it works

It works because a tapGestureRecognizer is added to the headerView, so the headerView can send callback when selection occurs.

How to make a foldable tableview

In the headerView selection callback method tableView:didSelectHeaderView:inSection: and tableView:didSelectHeaderView:inSection:, refresh the section in where the headerView lays, returning the corresponding number of row of the section, done!

It works like:

About

Extension for the UITableView that allows a user to select the headerView of tableView and call back, can be used to make a foldable tableView.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published