klyngbaek klyngbaek - 1 year ago 60
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.


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.