Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I catch touch events to a UITableView section header?

I've implemented a custom view for my UITableView section headers (via viewForHeaderInSection). When in plain view mode, the default behavior seems to be that the cells float underneath the section headers and touch events fall through to the cells underneath.

How can I have the custom section header view respond first to any touch events inside its bounds and take some action, rather than passing the event to the cell underneath the section header view?

like image 545
Christopher Scott Avatar asked Mar 07 '09 05:03

Christopher Scott


2 Answers

Use an UIControl instead of an UIView with

[aControl addTarget:<target> action: @selector(<desiredSelector:>) forControlEvents:UIControlEventTouchUpInside];
like image 177
catlan Avatar answered Oct 03 '22 21:10

catlan


See http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html It catch the tap events and perform action method. It may help you.

like image 45
Gaurav Avatar answered Oct 03 '22 22:10

Gaurav