Reputation: 1240
I have 2 UIButtons inside a myCustomCell Class which is a subclass of UITableViewCell.
The black Outline is the cell (UITableViewCell *) which is returned by 'cellForRowAtIndex'. This cell contains 'myCustomCell' as a subview. 'myCustomCell' has two UIButtons and the following properties :
backgroundcolor = clearColor
opaque = NO
On clicking anywhere in the cell except for the two Red Boxes(UI Buttons), I want the 'didSelectRowAtIndexPath' be triggered. But if the user clicks on the UIButton, only the selector for the target needs to be triggered, and not the 'didSelectRowAtIndexPath'. How can I achieve this ?
Upvotes: 3
Views: 3861
Reputation: 2678
if you build the cell as you mentioned above : the myCustomCell represent a subview inside the cell and it has two buttons inside it, each button has action, this should work as following; when you click on the button the didSelectRowAtIndexPath will not work and the button will handle the touch event since the touch hierarchy will be observed by the first action wich is the button and will not continue to the didSelectRowAtIndexPath and when you tab every where except buttons the didSelectRowAtIndexPath will handle the touch since there no observer handle this touch event and it will reach the didSelectRowAtIndexPath
Upvotes: 8