user440096
user440096

Reputation:

Is there a way to make a UITableViews sections handle touch events?

Is there a simple way or methods for allowing touches to be handled in sections(headings) and to track which section(heading) was touched?

I only want to draw the cells for a section when the user presses that section. But i want all the sections to always be visible.

I know i can hack that by make the headings be represented as cells and then draw extra cells below that cell when its touched. But its kinda hacky i guess.

Thanks, Code

Upvotes: 0

Views: 337

Answers (1)

BoltClock
BoltClock

Reputation: 724132

An easy way is to provide a custom section header view for your table view that contains some control, like a button, that can handle those touches for you.

Take a look at UITableViewDelegate's viewForHeaderInSection: method. You can use the section number that comes from that method to identify which section of cells to reveal as the user touches a button in that section header view.

Upvotes: 1

Related Questions