klyngbaek klyngbaek - 1 year ago 145
iOS Question

uitableviewcontroller select header for section

I have a UITableView with multiple sections. Each section has a section header (a custom view) is there an easy way to detect when someone selects the section header? (Just like didSelectRowAtIndexPath, but for the header?)

Thanks in advance.

Answer Source

No there is no way to do it with the UITableViewDelegate.

What you can do is add a button the size of the section header view and add it to the view. Set the tag of the button to the section index. Then just add the viewcontroller as a traget for the UIControlEventTouchUpInside.

Then by looking at the tag of the button you can see which section is clicked.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download